I have been looking around for a webview plugin in flutter that can detect when the url changes, but didn't find a match? The reason I am trying to detect a url change is because I want to change a bool variable to true when changed, which will then change the color of a appbar, is this possible?Are there any simple/easy examples out there that can achieve what i'm looking for? Thanks for any help in advance!
You can use StreamSubscription
.
StreamSubscription<String> _onStateChanged;
final flutterWebviewPlugin = new FlutterWebviewPlugin();
@override
void initState() {
super.initState();
_onStateChanged =
flutterWebviewPlugin.onUrlChanged.listen((String state) async {
if (state.startsWith('your_url')) {
// do whatever you want
}
});
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With