flutter_simple_webview 1.0.0
flutter_simple_webview: ^1.0.0 copied to clipboard
A Flutter package to easily display web content from a given URL with built-in internet connectivity checks and error handling.
Flutter Simple WebView (Smart Edition) ๐ #
A production-ready, ultra-lightweight, and feature-rich WebView for Flutter. Designed to handle the "hard stuff" like File Uploads, Authenticated Downloads, Permission Management, and Deep Linking automatically.
โจ Features #
- ๏ฟฝ Native File Picker: Full support for
<input type="file">on Android and iOS (Camera, Gallery, Files). - โฌ๏ธ Smart Downloads: Intercepts downloadable links (
.pdf,.zip,.png, etc.) and handles them via a background manager. - ๐ช Cookie Persistence: Built-in cookie management for seamless Odoo, SAP, or ERP sessions.
- ๐ก Zero-Dependency Connectivity: Uses raw
dart:iologic to detect internet status without bloating your bundle. - ๐ Auto-Permissions: Requests Camera, Microphone, and Storage permissions only when needed.
- ๐ Deep Link Handler: Supports
tel:,mailto:,whatsapp:, and custom external schemes. - ๐จ Fully Customizable: Control every aspect of the UI (AppBar, Colors, Progress Indicator).
- ๐ JS Bridge: Simple bi-directional communication between Flutter and JavaScript.
- ๐ก๏ธ Error Handling: Beautiful built-in Offline and Error screens.
๐ฆ Installation #
Add this to your pubspec.yaml:
dependencies:
flutter_simple_webview: ^1.0.0
๐ ๏ธ Platform Setup #
Android #
Add permissions to android/app/src/main/AndroidManifest.xml:
<manifest ...>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
</manifest>
iOS #
Add these keys to ios/Runner/Info.plist:
<key>NSCameraUsageDescription</key>
<string>We need camera access to upload photos from the webview.</string>
<key>NSMicrophoneUsageDescription</key>
<string>We need microphone access for audio recording.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>We need access to your photos to allow file uploads.</string>
๐ Usage #
1. Basic Usage #
The simplest way to get up and running.
import 'package:flutter_simple_webview/flutter_simple_webview.dart';
class MyPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const FlutterSimpleWebView(
url: 'https://flutter.dev',
title: 'Flutter Website',
);
}
}
2. Advanced / ERP Configuration #
Perfect for Odoo or custom enterprise apps requiring session management.
FlutterSimpleWebView(
url: 'https://my-odoo-erp.com',
title: 'Company Portal',
showAppBar: true,
appBarColor: Colors.indigo,
accentColor: Colors.orange,
enableJsBridge: true,
onJsMessage: (name, data) {
print("JS Event: $name, Data: $data");
},
initialCookies: [
Cookie('session_id', 'xyz123')
..domain = 'my-odoo-erp.com'
],
)
๐ API Reference #
| Parameter | Type | Default | Description |
|---|---|---|---|
url |
String |
Required | The target website URL to load. |
title |
String? |
"WebView" |
The text displayed in the AppBar. |
showAppBar |
bool |
true |
Whether to show the standard Scaffold AppBar. |
appBarColor |
Color? |
Theme primary |
Background color for the AppBar. |
accentColor |
Color? |
Theme accent |
Color for the progress bar and buttons. |
headers |
Map? |
null |
Custom HTTP headers for the initial request. |
enableJsBridge |
bool |
false |
Enable FlutterBridge JS channel. |
initialCookies |
List<Cookie>? |
null |
Pre-set cookies before loading the URL. |
๐ง How It Works #
Connectivity Management #
Unlike many packages that rely on heavy plugins, this package uses a raw internet probe (InternetAddress.lookup). It detects true internet access (not just Wi-Fi connection) and handles offline states with a polished UI.
File Handling #
- Uploads: Automatically triggers the native OS file picker when the WebView requests a file selector.
- Downloads: Intercepts URLs with common file extensions. It preserves session cookies to ensure you can download files from password-protected ERP sections.
๐ค Contributing #
Contributions are welcome! Feel free to open issues or submit pull requests to help make this package even better.
๐ License #
This project is licensed under the MIT License - see the LICENSE file for details. Designed with โค๏ธ for the Flutter community.