I noticed that whenever I click the webview for the 2nd time . onUrlChanged listen ( duplicate ) the same data .
[✓] Flutter (Channel stable, v1.17.5, on Mac OS X 10.15.2 19C57,
locale en-MY)
• Flutter version 1.17.5 at /Users/Users/flutter
• Framework revision 8af6b2f038 (7 weeks ago), 2020-06-30
12:53:55 -0700
• Engine revision ee76268252
• Dart version 2.8.4
[✓] Android toolchain - develop for Android devices (Android SDK
version 30.0.1)
• Android SDK at /Users/Users/Library/Android/sdk
• Platform android-30, build-tools 30.0.1
• Java binary at: /Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
1.8.0_242-release-1644-b3-6222593)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.4.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.4.1, Build version 11E503a
• CocoaPods version 1.8.4
[✓] Android Studio (version 4.0)
• Android Studio at /Applications/Android
Studio.app/Contents
• Flutter plugin version 47.1.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build
1.8.0_242-release-1644-b3-6222593)
[✓] VS Code (version 1.48.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.13.2
I noticed that whenever I click the webview for the 2nd time . onUrlChanged listen ( duplicate ) the same data .
[✓] Flutter (Channel stable, v1.17.5, on Mac OS X 10.15.2 19C57, locale en-MY) • Flutter version 1.17.5 at /Users/Users/flutter • Framework revision 8af6b2f038 (7 weeks ago), 2020-06-30 12:53:55 -0700 • Engine revision ee76268252 • Dart version 2.8.4 [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.1) • Android SDK at /Users/Users/Library/Android/sdk • Platform android-30, build-tools 30.0.1 • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593) • All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.4.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 11.4.1, Build version 11E503a • CocoaPods version 1.8.4
[✓] Android Studio (version 4.0) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin version 47.1.2 • Dart plugin version 193.7361 • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
[✓] VS Code (version 1.48.1) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.13.2
`final flutterWebViewPlugin = FlutterWebviewPlugin(); StreamSubscription _onUrlChanged;
@override void initState() { super.initState(); flutterWebViewPlugin.close(); _onUrlChanged = flutterWebViewPlugin.onUrlChanged.listen((url) { if (mounted) { if (url.contains( '${EnviromentConfig.baseUrl}/?status_id=1')) { Uri uri = Uri.parse(url); _redirect(uri); } else if (url.contains( '${EnviromentConfig.baseUrl}/?statusid=0')) { Uri uri = Uri.parse(url); String message = uri.queryParameters['message'].replaceAll('', ' '); Navigator.pop(_scaffoldKey.currentContext); final snackBar = SnackBar(backgroundColor: Colors.red, content: Text(message)); _scaffoldKey.currentState.showSnackBar(snackBar); } } }); }
@override void dispose() { _onUrlChanged.cancel(); flutterWebViewPlugin.dispose(); super.dispose(); }`