Google Flutter web view allows you to display a web page in your mobile app.
webview_flutter: ^0.3.14+1
When you save the yaml file, it will automatically run "flutter packages get" command to install webview plug into your project.
For iOS, you also need to add to plist:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoadsInWebContent</key>
<true/>
</dict>
Next, import the package in you screen,
import 'package:webview_flutter/webview_flutter.dart';
Then, you can simply add a webview widget in you page:
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: WebView(initialUrl: 'https://google.com'),
);
}
If you need to run javascript, add the following attribute to WebView.
javascriptMode: JavascriptMode.unrestricted,
You can also use WebViewController to change the URL:
onWebViewCreated: (WebViewController webViewController) {
controller = webViewController;}