WebView 是一个重要的控件,它用来加载网页、HTML、文件等。它的使用也很简单。今天就学习下Flutter下的WebView如何加载网页。
使用教程地址:https://pub.flutter-io.cn/packages/flutter_webview_plugin#-installing-tab-
安装flutter_webview_plugin插件
- Add this to your package’s
pubspec.yaml
file:
dependencies:
flutter_webview_plugin: ^0.3.5
- You can install packages from the command line:
$ flutter pub get
-
查看插件安装成功与否:左侧flutter_webview_plugin包出现
-
导入使用
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
- 加载百度页面效果
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child:new WebviewScaffold(
url: "https://www.baidu.com",
appBar: new AppBar(
title: new Text("加载了百度"),
),
),
),
加载出来了。。。在公司电脑死活不出来,气死我了。以后不用公司电脑配置环境了。
注意⚠️:
如果导入插件时,报gradle-3.2.1.pom
的错误。就重启一下电脑吧!
> Could not resolve all artifacts for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:3.2.1.
Required by:
project :
> Could not resolve com.android.tools.build:gradle:3.2.1.
> Could not get resource 'https://maven.aliyun.com/repository/google/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'