Plugin that allows Flutter to communicate with a native WebView.
Warning: The webview is not integrated in the widget tree, it is a native view on top of the flutter view. you won't be able to use snackbars, dialogs ...
For help getting started with Flutter, view our online documentation.
new MaterialApp(
routes: {
"/": (_) => new WebviewScaffold(
url: "https://www.google.com",
appBar: new AppBar(
title: new Text("Widget webview"),
),
),
},
);
Optional parameters hidden
and initialChild
are available so that you can show something else while waiting for the page to load.
If you set hidden
to true it will show a default CircularProgressIndicator. If you additionally specify a Widget for initialChild
you can have it display whatever you like till page-load.
e.g. The following will show a read screen with the text 'waiting.....'.
return new MaterialApp(
title: 'Flutter WebView Demo',
theme: new ThemeData(
primarySwatch: Colors.blue,
),
routes: {
'/': (_) => const MyHomePage(title: 'Flutter WebView Demo'),
'/widget': (_) => new WebviewScaffold(
url: selectedUrl,
appBar: new AppBar(
title: const Text('Widget webview'),
),
withZoom: true,
withLocalStorage: true,
hidden: true,
initialChild: Container(
color: Colors.redAccent,
child: const Center(
child: Text('Waiting.....'),
),
),
),
},
);
FlutterWebviewPlugin
provide a singleton instance linked to one unique webview,
so you can take control of the webview from anywhere in the app
listen for events
final flutterWebviewPlugin = new FlutterWebviewPlugin();
flutterWebviewPlugin.onUrlChanged.listen((String url) {
});
final flutterWebviewPlugin = new FlutterWebviewPlugin();
flutterWebviewPlugin.onScrollYChanged.listen((double offsetY) { // latest offset value in vertical scroll
// compare vertical scroll changes here with old value
});
flutterWebviewPlugin.onScrollXChanged.listen((double offsetX) { // latest offset value in horizontal scroll
// compare horizontal scroll changes here with old value
});
Note: Do note there is a slight difference is scroll distance between ios and android. Android scroll value difference tends to be larger than ios devices.
final flutterWebviewPlugin = new FlutterWebviewPlugin();
flutterWebviewPlugin.launch(url, hidden: true);
flutterWebviewPlugin.close();
final flutterWebviewPlugin = new FlutterWebviewPlugin();
flutterWebviewPlugin.launch(url,
fullScreen: false,
rect: new Rect.fromLTWH(
0.0,
0.0,
MediaQuery.of(context).size.width,
300.0,
),
);
Stream<Null>
onDestroyStream<String>
onUrlChangedStream<WebViewStateChanged>
onStateChangedStream<double>
onScrollXChangedStream<double>
onScrollYChangedStream<String>
onErrorDon't forget to dispose webview
flutterWebviewPlugin.dispose()
Future<Null> launch(String url, {
Map<String, String> headers: null,
bool withJavascript: true,
bool clearCache: false,
bool clearCookies: false,
bool hidden: false,
bool enableAppScheme: true,
Rect rect: null,
String userAgent: null,
bool withZoom: false,
bool withLocalStorage: true,
bool withLocalUrl: true,
bool scrollBar: true,
bool supportMultipleWindows: false,
bool appCacheEnabled: false,
bool allowFileURLs: false,
});
Future<String> evalJavascript(String code);
Future<Map<String, dynamic>> getCookies();
Future<Null> cleanCookies();
Future<Null> resize(Rect rect);
Future<Null> show();
Future<Null> hide();
Future<Null> reloadUrl(String url);
Future<Null> close();
Future<Null> reload();
Future<Null> goBack();
Future<Null> goForward();
Future<Null> stopLoading();
>= 0.10.2
.clearCookies
feature.hidden
and initialChild
feature to show page loading view.file://
local file URLs.reload
, goBack
, and goForward
.didFailNavigation
#77compileSdkVersion
to 27
matching offical Flutter plugins.reloadUrl
so settings are not cleared.Mixed Content Mode
on Android.iOS && Android:
Android
Add WebviewScaffold
example/README.md
Demonstrates how to use the flutter_webview_plugin plugin.
For help getting started with Flutter, view our online documentation.
Add this to your package's pubspec.yaml file:
dependencies:
flutter_webview_plugin: ^0.3.0+1
You can install packages from the command line:
with Flutter:
$ flutter packages get
Alternatively, your editor might support flutter packages get
.
Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
Version | Uploaded | Documentation | Archive |
---|---|---|---|
0.3.0+2 | Nov 15, 2018 |
|
|
0.3.0+1 | Nov 15, 2018 |
|
|
0.3.0 | Nov 15, 2018 |
|
|
0.2.1+2 | Aug 8, 2018 |
|
|
0.2.1+1 | Aug 7, 2018 |
|
|
0.2.1 | Aug 5, 2018 |
|
|
0.2.0 | Aug 1, 2018 |
|
|
0.1.6 | May 24, 2018 |
|
|
0.1.5 | Apr 1, 2018 |
|
|
0.1.4 | Mar 25, 2018 |
|
|
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
99
|
Health:
Code health derived from static analysis.
[more]
|
100
|
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
100
|
Overall:
Weighted score of the above.
[more]
|
100
|
We analyzed this package on Feb 14, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
Detected platforms: Flutter
References Flutter, and has no conflicting libraries.
Format lib/src/base.dart
.
Run flutter format
to format lib/src/base.dart
.
Format lib/src/webview_scaffold.dart
.
Run flutter format
to format lib/src/webview_scaffold.dart
.
Package | Constraint | Resolved | Available |
---|---|---|---|
Direct dependencies | |||
Dart SDK | >=2.0.0 <3.0.0 | ||
flutter | 0.0.0 | ||
Transitive dependencies | |||
collection | 1.14.11 | ||
meta | 1.1.6 | 1.1.7 | |
sky_engine | 0.0.99 | ||
typed_data | 1.1.6 | ||
vector_math | 2.0.8 |