gongyuan 5fbcd317b4 feat:first commit; | 1 년 전 | |
---|---|---|
.. | ||
lib | 1 년 전 | |
test | 1 년 전 | |
webview_flutter_android | 1 년 전 | |
webview_flutter_platform_interface | 1 년 전 | |
webview_flutter_wkwebview | 1 년 전 | |
AUTHORS | 1 년 전 | |
CHANGELOG.md | 1 년 전 | |
LICENSE | 1 년 전 | |
README.md | 1 년 전 | |
pubspec.yaml | 1 년 전 |
A Flutter plugin that provides a WebView widget.
On iOS the WebView widget is backed by a WKWebView; On Android the WebView widget is backed by a WebView.
Add webview_flutter
as a dependency in your pubspec.yaml file. If you are targeting Android, make sure to read the Android Platform Views section below to choose the platform view mode that best suits your needs.
You can now include a WebView widget in your widget tree. See the WebView widget's Dartdoc for more details on how to use the widget.
The WebView is relying on Platform Views to embed the Android’s webview within the Flutter app. It supports two modes: Virtual displays (the current default) and Hybrid composition.
Here are some points to consider when choosing between the two:
Hybrid composition | Virtual displays | |
---|---|---|
Full keyboard supoport | yes | no |
Android SDK support | 19+ | 20+ |
Full performance | Android 10+ | always |
The default | no | yes |
The mode is currently enabled by default. You should however make sure to set the correct minSdkVersion
in android/app/build.gradle
(if it was previously lower than 20):
android {
defaultConfig {
minSdkVersion 20
}
}
Set the correct minSdkVersion
in android/app/build.gradle
(if it was previously lower than 19):
android {
defaultConfig {
minSdkVersion 19
}
}
Set WebView.platform = SurfaceAndroidWebView();
in initState()
.
For example:
import 'dart:io';
import 'package:webview_flutter/webview_flutter.dart';
class WebViewExample extends StatefulWidget {
@override
WebViewExampleState createState() => WebViewExampleState();
}
class WebViewExampleState extends State<WebViewExample> {
@override
void initState() {
super.initState();
// Enable hybrid composition.
if (Platform.isAndroid) WebView.platform = SurfaceAndroidWebView();
}
@override
Widget build(BuildContext context) {
return WebView(
initialUrl: 'https://flutter.dev',
);
}
}
To use Material Components when the user interacts with input elements in the WebView, follow the steps described in the Enabling Material Components instructions.