Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
17
Help us understand the problem. What is going on with this article?
@Horie1024

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

17
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  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
zozotech
70億人のファッションを技術の力で変えていく

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
17
Help us understand the problem. What is going on with this article?