The package gives you Browser,
a Flutter widget for displaying web pages.
The package is built on top of webview_flutter and it
adds navigation widgets that:
Display the domain.
Allow user to tap "back", "forward", "refresh", or share the URL using a native dialog of each
platform.
Display website loading error messages in a visually pleasant and easy-to-understand way.
Browser has been tested in Android, iOS, and browsers. By adding relevant "webview_flutter"
plugin dependencies to your "pubspec.yaml", you can use this package in Windows, Mac OS X, and
Linux too.
The package contains two designs, Cupertino (web_browser.cupertino)
and Material (web_browser.material).
By default, the package chooses a Cupertino or Material design based on whether the app is CupertinoApp or MaterialApp.
You can override the defaults by using relevant parameters of
Browser()
constructor.
The Cupertino and Material navigation bars look like this:
import'package:flutter/material.dart';
import'package:web_browser/web_browser.dart';
voidmain() {
runApp(constMaterialApp(
home: Scaffold(
body: SafeArea(
child: Browser(
initialUriString: 'https://flutter.dev/',
controller: BrowserController(
// "User-Agent" HTTP header.
userAgent: 'Your user agent',
// Can user zoom into the content? Default is true.
isZoomingEnabled: false,
)
),
),
),
));
}
Cache clearing
For end-users privacy, it is good to clear:
Cookies
Caches
Local storage
You can enable this by setting:
import'package:web_browser/web_browser.dart';
voidmain() {
// Clear when the app is startedBrowserController.resetGlobalStateAtStart = true;
// Clear every now and then.BrowserController.globalStateExpiration = constDuration(days: 1);
// ...
}