fluttercommunity / fluttercommunity/flutter_webview_plugin

onUrlChanged always listen even I cancel the subscription & dispose the webview

Aperta
#809 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Java
Stelle
1.5k
Fork
938
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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}/?status_id=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();
}`

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Start with the onUrlChanged subscription and the dispose lifecycle shown in the report, then reproduce the second webview interaction using the supplied example. Trace whether cancellation and webview disposal stop callbacks; done means a later webview interaction does not deliver duplicate URL-change events.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
dart, flutter
Ambito
mobile-dev
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.