【自学Flutter】38 flutter_webview_plugin的使用

38 flutter_webview_plugin的使用

1.源代码

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

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body:  WebviewScaffold(
          url: "http://www.baidu.com",
          appBar: new AppBar(
            title: new Text("flutter_webview_plugin的使用"),
          ),
        ),
      ),
    );
  }
}

2.引用

flutter_webview_plugin: ^0.3.5

【自学Flutter】38 flutter_webview_plugin的使用_第1张图片

3.解释源代码

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

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body:  WebviewScaffold(
          //要打开的网址
          url: "http://www.baidu.com",
          appBar: new AppBar(
            title: new Text("flutter_webview_plugin的使用"),
          ),
        ),
      ),
    );
  }
}

4.效果图

【自学Flutter】38 flutter_webview_plugin的使用_第2张图片

你可能感兴趣的:(自学Flutter)