WebView In Flutter
WebSite into App
Published in
Oct 6, 2020
This blog will cover all the errors while making an webView app
Get the packages updated version here
Setting up packages
Step 1: Adding dependencies
Add the package at pubspec.yaml
file.
dependencies:
flutter:
sdk: flutter
webview_flutter: ^0.3.22+1
Step-2: Importing
import 'package:webview_flutter/webview_flutter.dart';
Setting up Files Permisions
1. Add Internet permission
<uses-permission android:name="android.permission.INTERNET" />
Add this line in file AndroidManifest.xml
file path: android/app/src/main/AndroidManifest.xml
2. Add this key for iOS
<key>io.flutter.embedded_views_preview</key>
<string>YES</string>
file path:
iOS/Runner/Info.plist
3. Add full url (with http://www
)
return Scaffold(
appBar: AppBar(
title: const Text('Flutter WebView example'),
),
body: const WebView(
initialUrl: 'https://flutter.io',
javascriptMode: JavascriptMode.unrestricted,
),
);
JavaScriptMode is restricted default. Unrestricted it by adding javascriptMode: JavascriptMode.unrestricted,