diff --git a/CHANGELOG.md b/CHANGELOG.md
index 715550f..fdcfb6e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,6 @@
+## 0.6.1
+* Small fixes.
+
## 0.6.0
* Many improvements.
diff --git a/README.md b/README.md
index 0fbfbff..9292751 100644
--- a/README.md
+++ b/README.md
@@ -38,18 +38,7 @@ void main() {
home: Scaffold(
body: SafeArea(
child: WebBrowser(
- initialUrl: 'https://flutter.dev/',
- policy: BrowserPolicy(
- allowedDomains: {
- // Allow navigation to "flutter.dev" and any subdomain.
- // Other websites will be opened in the user's browser.
- '**.flutter.dev',
-
- // And some other websites...
- '**.dart.dev',
- '**.youtube.com',
- },
- )
+ initialUriString: 'https://flutter.dev/',
),
),
),
@@ -58,6 +47,16 @@ void main() {
```
# Designs available in this package
+### Cupertino design
+* [CupertinoBrowserTopBar](https://pub.dev/documentation/web_browser/latest/web_browser.cupertino/CupertinoBrowserTopBar-class.html)
+* [CupertinoBrowserBottomBar](https://pub.dev/documentation/web_browser/latest/web_browser.cupertino/CupertinoBrowserBottomBar-class.html)
+ with:
+ * [CupertinoBrowserBackButton](https://pub.dev/documentation/web_browser/latest/web_browser.cupertino/CupertinoBrowserBackButton-class.html)
+ * [CupertinoBrowserForwardButton](https://pub.dev/documentation/web_browser/latest/web_browser.cupertino/CupertinoBrowserForwardButton-class.html)
+ * [CupertinoBrowserRefreshButton](https://pub.dev/documentation/web_browser/latest/web_browser.cupertino/CupertinoBrowserRefreshButton-class.html)
+
+
+
### Material design
* [MaterialBrowserTopBar](https://pub.dev/documentation/web_browser/latest/web_browser.material/MaterialBrowserTopBar-class.html)
* [MaterialBrowserBottomBar](https://pub.dev/documentation/web_browser/latest/web_browser.material/MaterialBrowserBottomBar-class.html)
@@ -66,13 +65,7 @@ void main() {
* [MaterialBrowserForwardButton](https://pub.dev/documentation/web_browser/latest/web_browser.material/MaterialBrowserForwardButton-class.html)
* [MaterialBrowserRefreshButton](https://pub.dev/documentation/web_browser/latest/web_browser.material/MaterialBrowserRefreshButton-class.html)
-### Cupertino design
-* [CupertinoBrowserTopBar](https://pub.dev/documentation/web_browser/latest/web_browser.cupertino/CupertinoBrowserTopBar-class.html)
-* [CupertinoBrowserBottomBar](https://pub.dev/documentation/web_browser/latest/web_browser.cupertino/CupertinoBrowserBottomBar-class.html)
- with:
- * [CupertinoBrowserBackButton](https://pub.dev/documentation/web_browser/latest/web_browser.cupertino/CupertinoBrowserBackButton-class.html)
- * [CupertinoBrowserForwardButton](https://pub.dev/documentation/web_browser/latest/web_browser.cupertino/CupertinoBrowserForwardButton-class.html)
- * [CupertinoBrowserRefreshButton](https://pub.dev/documentation/web_browser/latest/web_browser.cupertino/CupertinoBrowserRefreshButton-class.html)
+
## Auto-design (default)
By default, the package chooses Material or Cupertino design based on whether the app is
diff --git a/example/android/app/src/debug/AndroidManifest.xml b/example/android/app/src/debug/AndroidManifest.xml
index 45d523a..3a24bb3 100644
--- a/example/android/app/src/debug/AndroidManifest.xml
+++ b/example/android/app/src/debug/AndroidManifest.xml
@@ -5,4 +5,5 @@
to allow setting breakpoints, to provide hot reload, etc.
-->
+
diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml
index 3f41384..55ed516 100644
--- a/example/android/app/src/main/AndroidManifest.xml
+++ b/example/android/app/src/main/AndroidManifest.xml
@@ -31,4 +31,6 @@
android:name="flutterEmbedding"
android:value="2" />
+
+
diff --git a/example/android/app/src/profile/AndroidManifest.xml b/example/android/app/src/profile/AndroidManifest.xml
index 45d523a..3a24bb3 100644
--- a/example/android/app/src/profile/AndroidManifest.xml
+++ b/example/android/app/src/profile/AndroidManifest.xml
@@ -5,4 +5,5 @@
to allow setting breakpoints, to provide hot reload, etc.
-->
+
diff --git a/example/lib/main.dart b/example/lib/main.dart
index a468a1a..65faf02 100644
--- a/example/lib/main.dart
+++ b/example/lib/main.dart
@@ -1,49 +1,29 @@
-import 'package:flutter/material.dart';
+import 'package:flutter/cupertino.dart';
import 'package:web_browser/web_browser.dart';
void main() {
- // const app = CupertinoApp(
- // title: 'Example',
- // home: CupertinoPageScaffold(
- // child: SafeArea(
- // child: Browser(
- // initialUriString: 'https://dart.dev/',
- // policy: BrowserPolicy(
- // allowedDomains: {
- // // Allow navigation to flutter.dev and any subdomain.
- // // Other websites will be opened in the user's browser.
- // '**.flutter.dev',
- //
- // // And some other websites...
- // '**.dart.dev',
- // '**.youtube.com',
- // },
- // ),
- // ),
- // ),
- // ),
- // );
- const app = MaterialApp(
+ const app = CupertinoApp(
title: 'Example',
- home: Scaffold(
- body: SafeArea(
+ debugShowCheckedModeBanner: false,
+ home: CupertinoPageScaffold(
+ child: SafeArea(
child: Browser(
- initialUriString: 'https://dart.dev/',
- policy: BrowserPolicy(
- allowedDomains: {
- // Allow navigation to flutter.dev and any subdomain.
- // Other websites will be opened in the user's browser.
- '**.flutter.dev',
-
- // And some other websites...
- '**.dart.dev',
- '**.youtube.com',
- },
- ),
+ initialUriString: 'https://flutter.dev/',
),
),
),
);
+ // const app = MaterialApp(
+ // title: 'Example',
+ // debugShowCheckedModeBanner: false,
+ // home: Scaffold(
+ // body: SafeArea(
+ // child: Browser(
+ // initialUriString: 'https://flutter.dev/',
+ // ),
+ // ),
+ // ),
+ // );
runApp(app);
}
diff --git a/lib/basic.dart b/lib/basic.dart
index 0a320e3..b5f0930 100644
--- a/lib/basic.dart
+++ b/lib/basic.dart
@@ -20,3 +20,4 @@ library web_browser.basic;
export 'src/basic/basic_browser_address_field.dart';
export 'src/basic/basic_browser_bottom_dialog.dart';
+export 'src/basic/basic_browser_error_widget.dart';
diff --git a/lib/src/basic/basic_browser_error_widget.dart b/lib/src/basic/basic_browser_error_widget.dart
index 170dbda..c132fe9 100644
--- a/lib/src/basic/basic_browser_error_widget.dart
+++ b/lib/src/basic/basic_browser_error_widget.dart
@@ -1,5 +1,6 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
+import 'package:web_browser/src/web_browser/browser_localizations.dart';
import 'package:webview_flutter/webview_flutter.dart';
/// A widget that may be used to replace [WebViewWidget] when an error occurs.
@@ -20,9 +21,14 @@ class BasicBrowserErrorWidget extends StatelessWidget {
required WebResourceError error,
required Widget? refreshButton,
}) {
+ final localizations = Localizations.of(
+ context,
+ BrowserLocalizations,
+ ) ??
+ const BrowserLocalizations();
return BasicBrowserErrorWidget(
- title: const Text(
- 'Could not reach the website :(',
+ title: Text(
+ localizations.couldNotReach,
textAlign: TextAlign.center,
),
body: Column(
diff --git a/lib/src/web_browser/browser.dart b/lib/src/web_browser/browser.dart
index edc12a8..2ca84e9 100644
--- a/lib/src/web_browser/browser.dart
+++ b/lib/src/web_browser/browser.dart
@@ -16,12 +16,11 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:share_plus/share_plus.dart' as share_plus;
-import 'package:web_browser/src/basic/basic_browser_error_widget.dart';
-import 'package:web_browser/src/web_browser/browser_controller.dart';
-import 'package:web_browser/src/web_browser/browser_policy.dart';
import 'package:webview_flutter/webview_flutter.dart';
import '../../auto.dart';
+import '../../basic.dart';
+import '../../web_browser.dart';
/// A web browser widget with navigation buttons and other features.
///
@@ -96,7 +95,12 @@ class Browser extends StatefulWidget {
/// Default callback for [onError].
static Widget defaultOnError(BuildContext context,
BrowserController controller, WebResourceError error) {
- const label = Text('Try again');
+ final localizations = Localizations.of(
+ context,
+ BrowserLocalizations,
+ ) ??
+ const BrowserLocalizations();
+ final label = Text(localizations.tryAgain);
void onPressed() {
Browser.of(context).controller.refresh();
}
diff --git a/lib/src/web_browser/browser_controller.dart b/lib/src/web_browser/browser_controller.dart
index 7a23444..84bc493 100644
--- a/lib/src/web_browser/browser_controller.dart
+++ b/lib/src/web_browser/browser_controller.dart
@@ -83,13 +83,18 @@ class BrowserController extends ChangeNotifier {
if (!kIsWeb) {
try {
if (_isAndroid) {
- // Do other platforms than Android give "canGoBlack" data?
_webViewController.canGoBack().then((value) {
- _canGoBack = value;
+ if (value != _canGoBack) {
+ _canGoBack = value;
+ notifyListeners();
+ }
}, onError: (error) {});
}
_webViewController.canGoForward().then((value) {
- _canGoForward = value;
+ if (value != _canGoForward) {
+ _canGoForward = value;
+ notifyListeners();
+ }
}, onError: (error) {});
} catch (error) {
// Ignore error
@@ -111,9 +116,11 @@ class BrowserController extends ChangeNotifier {
webViewNavigationDelegate?.onPageFinished?.call(uri);
},
onWebResourceError: (error) {
- _error = error;
- _isLoading = false;
- notifyListeners();
+ if (error.isForMainFrame ?? true) {
+ _error = error;
+ _isLoading = false;
+ notifyListeners();
+ }
webViewNavigationDelegate?.onWebResourceError?.call(error);
},
));
diff --git a/lib/src/web_browser/browser_localizations.dart b/lib/src/web_browser/browser_localizations.dart
index 793c0e0..bfbb1df 100644
--- a/lib/src/web_browser/browser_localizations.dart
+++ b/lib/src/web_browser/browser_localizations.dart
@@ -21,13 +21,17 @@ class BrowserLocalizations {
final String forward;
final String refresh;
- final String copy;
+ final String share;
+ final String couldNotReach;
+ final String tryAgain;
const BrowserLocalizations({
this.back = 'Back',
this.forward = 'Forward',
- this.copy = 'Copy',
this.refresh = 'Refresh',
+ this.share = 'Share',
+ this.couldNotReach = 'Could not reach the website.',
+ this.tryAgain = 'Try again.',
});
/// Constructs [LocalizationsDelegate] for the localization.
diff --git a/pubspec.yaml b/pubspec.yaml
index d30ef00..9972124 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,8 +1,8 @@
name: web_browser
-version: 0.6.0
+version: 0.6.1
description:
- A cross-platform Flutter widget for displaying websites and other web content. Has optional
- navigation buttons.
+ A cross-platform Flutter widget for displaying websites and other web content. Has navigation
+ Cupertino/Material buttons and takes care of complex platform differences.
homepage: https://github.com/dint-dev/web_browser
environment:
diff --git a/screenshots/cupertino.png b/screenshots/cupertino.png
new file mode 100644
index 0000000..89746b7
Binary files /dev/null and b/screenshots/cupertino.png differ
diff --git a/screenshots/material.png b/screenshots/material.png
new file mode 100644
index 0000000..60b7859
Binary files /dev/null and b/screenshots/material.png differ