Help us understand the problem. What is going on with this article?

FlutterでWebViewを表示する

More than 1 year has passed since last update.

概要

FlutterでWebViewを利用してWebサイトを表示する方法を調べたのでメモ。

インストール

flutter_webview_pluginを使用する。バージョンは0.1.6

pubspec.yamlに以下を追加

dependencies:
  flutter_webview_plugin: "^0.1.6"

コマンドラインで以下を実行しpackageをインストール

$ flutter packages get

Dartコードからは以下のようにimportして使用する

import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';

実装

以下のコードでWebViewを表示する。

import 'package:flutter/material.dart';
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(routes: {
      "/": (_) => new WebviewScaffold(
            url: "https://www.google.com",
            appBar: new AppBar(
              title: new Text("Widget webview"),
            ), // AppBar
          ) // WebviewScaffold
    }); // MaterialApp
  }
}

実行

iOS、Android共表示できた。

image.png

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away