webview_ultra 0.0.6+8
webview_ultra: ^0.0.6+8 copied to clipboard
An ultra-optimized, feature-complete, lightweight multi-platform webview plugin for Flutter (Android, iOS, macOS, Windows).
webview_ultra π #
An ultra-optimized, lightweight, and feature-complete multi-platform WebView plugin for Flutter.
Built directly on top of the official Google webview_flutter Pigeon engine (Android, iOS, macOS) and Microsoft Edge WebView2 (Windows), webview_ultra delivers 100% of the advanced power of flutter_inappwebview with zero binary bloat (~200 KB vs ~6 MB) and rock-solid engine stability.
π Repository & Links #
- GitHub Repository: https://github.com/Narukarudra10/webview_ultra
- Issue Tracker: https://github.com/Narukarudra10/webview_ultra/issues
- Example Application: example/
β¨ Feature Matrix & Comparison #
| Feature | webview_flutter |
flutter_inappwebview |
webview_ultra π |
|---|---|---|---|
| Binary Size / Overhead | ~200 KB | ~5β8 MB (Heavy) | ~200 KB (Ultra Light) |
| Official Engine Stability | β Native Pigeon | β Large custom surface | β Official Pigeon Core |
| 1-Line Drop-in Widget | β (30+ lines setup) | β | β Built-in UI & Shimmer |
Reactive State (ValueNotifier) |
β (Manual setState) |
β | β Zero-Screen-Rebuild |
| Typed Bidirectional JS Bridge | β (Raw strings only) | β | β Typed JSON-RPC & Promises |
User Scripts (DocumentStart/End) |
β οΈ Limited | β | β Cross-Platform UserScript |
| Headless Off-Screen Webview | β | β | β
HeadlessWebviewUltra |
| Modal In-App Browser | β | β | β
InAppBrowserUltra |
| Cookie & Storage Manager | β οΈ Basic | β | β
CookieManagerUltra |
| Content & Ad Blocker Engine | β | β | β Rule-based Regex Filter |
| Find on Page & Highlight | β | β | β
FindInteractionController |
| JS Dialog Interceptions | β οΈ Complex | β | β
alert, confirm, prompt |
File Upload & Choosers (<input type="file">) |
β οΈ Complex | β | β Auto Native + Custom Callback |
| Platform Support | Android, iOS, macOS | Android, iOS, Windows, macOS | Android, iOS, macOS, Windows |
π¦ Installation #
Add webview_ultra to your pubspec.yaml:
dependencies:
webview_ultra: ^0.0.6+8
Import the package in your Dart code:
import 'package:webview_ultra/webview_ultra.dart';
π Quick Start Guide #
1. Simple 1-Line Drop-in #
Zero configuration needed. Progress bar, error handling, and hardware acceleration are enabled by default:
import 'package:flutter/material.dart';
import 'package:webview_ultra/webview_ultra.dart';
class SimpleWebViewPage extends StatelessWidget {
const SimpleWebViewPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('WebviewUltra')),
body: const WebviewUltra(
initialUrl: 'https://flutter.cn',
showProgressBar: true,
pullToRefresh: true,
),
);
}
}
2. Zero-Screen-Rebuild Reactive State #
WebviewUltraController exposes fine-grained ValueNotifier instances. UI subtrees update independently without triggering expensive parent widget rebuilds:
final controller = WebviewUltraController();
Scaffold(
appBar: AppBar(
// 1. Rebuilds ONLY the title text
title: WebviewTitleBuilder(
controller: controller,
builder: (context, title, child) {
return Text(title.isEmpty ? 'Loading...' : title);
},
),
actions: [
// 2. Rebuilds ONLY the back/forward action buttons
WebviewHistoryBuilder(
controller: controller,
builder: (context, history, child) {
return IconButton(
icon: const Icon(Icons.arrow_back),
onPressed: history.canGoBack ? () => controller.goBack() : null,
);
},
),
],
// 3. Rebuilds ONLY the top progress bar
bottom: PreferredSize(
preferredSize: const Size.fromHeight(3.0),
child: WebviewProgressBuilder(
controller: controller,
builder: (context, progress, child) {
return progress < 1.0
? LinearProgressIndicator(value: progress)
: const SizedBox.shrink();
},
),
),
),
body: WebviewUltra(
controller: controller,
initialUrl: 'https://flutter.cn',
),
);
3. Bidirectional Typed JS-to-Dart RPC Bridge #
Execute typed Dart callbacks from JavaScript and receive Promise responses:
Dart Side:
controller.addJavaScriptHandler(
handlerName: 'onUserLogin',
callback: (args) {
final token = args[0]['token'];
print('User logged in: $token');
return {'status': 'authenticated', 'timestamp': DateTime.now().toIso8601String()};
},
);
JavaScript Side (inside Web page):
// Compatible with both webview_ultra and flutter_inappwebview syntax:
window.webview_ultra.callHandler('onUserLogin', { token: 'auth_jwt_token_123' })
.then(function(response) {
console.log('Dart response:', response.status);
});
4. Headless Webview (Background Execution) #
Run WebViews completely off-screen without placing any widget into the widget tree (for token retrieval, web scraping, SSR pre-rendering, or preheating):
final headless = HeadlessWebviewUltra(
initialUrl: 'https://flutter.cn',
onPageFinished: (url) async {
final title = await headless.evaluateJavascript('document.title');
print('Page title fetched in background: $title');
headless.dispose();
},
);
await headless.run();
5. InAppBrowser Modal #
Open a standalone modal browser complete with customizable navigation controls, dynamic address bar, reload, and close buttons:
InAppBrowserUltra.open(
context: context,
url: 'https://flutter.cn',
title: 'Flutter Portal',
);
6. Cross-Platform Cookie Manager #
Inspect, set, delete, and clear cookies across Android, iOS, macOS, and Windows:
// Set Cookie
await CookieManagerUltra.instance.setCookie(
url: 'https://flutter.cn',
name: 'session_id',
value: 'xyz_789',
);
// Clear All Cookies
await CookieManagerUltra.instance.clearCookies();
7. Content & Ad Blocking Engine #
Block requests and hide elements using regex filters, ifDomain, and unlessDomain:
final controller = WebviewUltraController(
contentBlockers: [
ContentBlocker(
trigger: ContentBlockerTrigger(
urlFilter: r'.*google-analytics\.com.*',
),
action: const ContentBlockerAction(
type: ContentBlockerActionType.block,
),
),
],
);
8. Find-on-Page Text Search & Highlighting #
Search and traverse text occurrences directly on the rendered page:
// Find all matches on the page
final count = await controller.findController.findAll(findText: 'Flutter');
// Navigate to next or previous match
await controller.findController.findNext(forward: true);
// Clear highlights
await controller.findController.clearMatches();
9. File Uploads & File Choosers (<input type="file">) #
Support HTML file pickers natively or customize file resolution via Flutter:
WebviewUltra(
initialUrl: 'https://html5demos.com/file-api/',
onShowFileChooser: (WebviewFileChooserParams params) async {
// Custom file picking using file_picker, image_picker, or local filesystem
debugPrint('File chooser triggered for mode: ${params.mode}, accept: ${params.acceptTypes}');
// Return a list of local file URIs / paths:
// return ['/storage/emulated/0/Download/document.pdf'];
return <String>[];
},
);
Platform Permissions Setup
- Android: Add camera/storage permissions in
AndroidManifest.xmlif your webpage captures photos or accesses media. - iOS: Add
NSCameraUsageDescription,NSPhotoLibraryUsageDescription, andNSMicrophoneUsageDescriptiontoios/Runner/Info.plist. - macOS: Add
com.apple.security.files.user-selected.read-onlytomacos/Runner/DebugProfile.entitlementsandRelease.entitlements. - Windows: Works automatically with system Win32 file dialogs.
π οΈ Multi-Platform Architecture #
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β WEBVIEW ULTRA β
β Unified Cross-Platform API (Android, iOS, macOS, Windows) β
ββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββ€
β 1. Reactive State & UI β 2. JavaScript & Interop β 3. Storage & Security β
β β’ ValueNotifier slices β β’ Typed JS RPC Bridge β β’ CookieManagerUltra β
β β’ WebviewUltra Widget β β’ UserScript Injection β β’ WebStorage & Cache β
β β’ Built-in Shimmer/Load β β’ Alert/Confirm/Prompt β β’ HTTP Auth & Custom SSL β
ββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββ€
β 4. Advanced Browsers β 5. Hardware & Media β 6. Content & Utilities β
β β’ HeadlessWebviewUltra β β’ Auto File Chooser β β’ ContentBlocker Rules β
β β’ InAppBrowserUltra β β’ WebRTC / Camera / Mic β β’ Find-on-Page & Highlighting β
β β’ Desktop Window Props β β’ Download Interceptor β β’ PDF Export & Print Engine β
ββββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββ€
β Platform Engine Drivers β
β π± Android: webview_flutter_android (WebView + Texture Layer Hybrid Composition) β
β π iOS: webview_flutter_wkwebview (WKWebView + WKUserContentController) β
β π» macOS: webview_flutter_wkwebview (WKWebView Desktop Bridge) β
β πͺ Windows: Microsoft Edge WebView2 (Chromium Engine Native Binding) β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π€ Contributing #
Contributions are welcome! Please check out the GitHub Issues to report bugs or submit feature requests.
π License #
This project is licensed under the MIT License - see the LICENSE file for details.