Browse Source

hotfix widget back to initialChild after tap action and add minSdkVersion on example gradle

Angga Dwi Arifandi 6 years ago
parent
commit
2a7a8a7592
2 changed files with 10 additions and 0 deletions
  1. 1 0
      example/android/app/build.gradle
  2. 9 0
      lib/src/webview_scaffold.dart

+ 1 - 0
example/android/app/build.gradle

@@ -25,6 +25,7 @@ android {
         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
         // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
         applicationId "com.yourcompany.flutter_webview_plugin_example"
+        minSdkVersion 16
     }
 
     buildTypes {

+ 9 - 0
lib/src/webview_scaffold.dart

@@ -63,11 +63,19 @@ class _WebviewScaffoldState extends State<WebviewScaffold> {
   Timer _resizeTimer;
   StreamSubscription<WebViewStateChanged> _onStateChanged;
 
+  var _onDestroy;
+
   @override
   void initState() {
     super.initState();
     webviewReference.close();
 
+    _onDestroy = webviewReference.onDestroy.listen((_) {
+      if (mounted) {
+        Navigator.of(context).pop();
+      }
+    });
+
     if (widget.hidden) {
       _onStateChanged = webviewReference.onStateChanged.listen((WebViewStateChanged state) {
         if (state.type == WebViewState.finishLoad) {
@@ -80,6 +88,7 @@ class _WebviewScaffoldState extends State<WebviewScaffold> {
   @override
   void dispose() {
     super.dispose();
+    _onDestroy?.cancel();
     _resizeTimer?.cancel();
     webviewReference.close();
     if (widget.hidden) {