flutter_inappwebview_forge 2.1.71
flutter_inappwebview_forge: ^2.1.71 copied to clipboard
A Flutter plugin that allows you to add an inline webview, to use an headless webview, and to open an in-app browser window.
flutter_inappwebview_forge #
A Flutter plugin for inline WebViews, headless WebViews, and in-app browser windows on Android, iOS, macOS, Windows, Linux, and Web.
This package is a maintained fork of Flutter InAppWebView. The Dart widget and controller model stays familiar while Forge owns the package names, native implementations, and releases.
Features #
- One Dart API across Android WebView, iOS/macOS
WKWebView, Windows WebView2, Linux WPE WebKit, and Web iframes InAppWebView,HeadlessInAppWebView, andInAppBrowser- Opt-in
InAppWebViewPreloaderfor starting a page before a route is shown - JavaScript handlers, user scripts, cookies, storage, and localhost serving
- Keep-alive, headless transfer, and idempotent disposal
- Runtime support checks for platform-specific features
Requirements #
- Dart SDK
^3.8.0 - Flutter
>=3.38.6 - Android
minSdkVersion >= 19 - iOS 15.0+
- macOS 10.14+
- Windows with the WebView2 runtime
- Linux with WPE WebKit 2.0 development packages
The iOS implementation requires Flutter 3.38.6 or newer. Earlier Flutter versions can still dispatch WebView gestures incorrectly on iOS.
Installation #
dependencies:
flutter_inappwebview_forge: ^2.1.71
flutter pub get
import 'package:flutter_inappwebview_forge/flutter_inappwebview_forge.dart';
Endorsed platform packages (android, ios, macos, windows, linux,
web) are included automatically. Do not depend on both
flutter_inappwebview and flutter_inappwebview_forge in the same app.
Quick start #
import 'package:flutter/material.dart';
import 'package:flutter_inappwebview_forge/flutter_inappwebview_forge.dart';
class BrowserPage extends StatefulWidget {
const BrowserPage({super.key});
@override
State<BrowserPage> createState() => _BrowserPageState();
}
class _BrowserPageState extends State<BrowserPage> {
InAppWebViewController? _controller;
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: InAppWebView(
initialUrlRequest: URLRequest(
url: WebUri('https://example.com'),
),
onWebViewCreated: (controller) {
_controller = controller;
},
onLoadStop: (controller, url) {
debugPrint('Loaded: $url');
},
),
),
);
}
}
Keep the controller in State, not in build(). Do not call loadUrl,
goBack, or evaluateJavascript before onWebViewCreated.
Android apps need android.permission.INTERNET. iOS HTTP pages need a scoped
ATS exception rather than disabling ATS globally. See the
getting started guide
for platform setup.
Preload a known page #
final preloader = InAppWebViewPreloader(
headlessWebView: HeadlessInAppWebView(
initialUrlRequest: URLRequest(
url: WebUri('https://example.com'),
),
),
);
await preloader.prewarm();
InAppWebView(
preloader: preloader,
onWebViewCreated: (controller) {
// This controller owns the transferred native WebView.
},
);
Keep the preloader alive until the inline WebView takes ownership.
Documentation #
- Getting started
- Examples
- Preload and reuse
- Platform guide
- Migration from upstream
- Changelog
- Repository
Migration from flutter_inappwebview #
dependencies:
flutter_inappwebview_forge: ^2.1.71
import 'package:flutter_inappwebview_forge/flutter_inappwebview_forge.dart';
InAppWebView and InAppWebViewController keep the same names. The Android
namespace is com.emirkanacar.flutter_inappwebview_forge_android.
Attribution and license #
Originally created and maintained by Lorenzo Pichilli with contributions from the open-source community. This fork is maintained by Emirkan Acar.
Distributed under the Apache License 2.0.