fluttercommunity / fluttercommunity/flutter_webview_plugin

The monitoring function is triggered twice under the same Url

Open
#862 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.5k
Forks
938
PR merge metrics
No merged PRs in 30d

Description

## System info

Issue occurs on: Android
Plugin version: 0.3.11
Flutter doctor output:
[✓] Flutter (Channel stable, 1.22.5, on Mac OS X 10.15.3 19D76 darwin-x64, locale
zh-Hans-CN)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
[✓] Android Studio (version 3.5)
[✓] IntelliJ IDEA Ultimate Edition (version 2019.3)
[✓] VS Code (version 1.52.1)
[✓] Connected device (1 available)

• No issues found!

```
paste it here...
```

## Steps to Reproduce

1. ...
```
@override
void initState() {
super.initState();
webviewPlugin.onUrlChanged.listen((url) {
// TODO:相同的地址会执行两次,bug
if (mounted) {
print("url changed: $url");
isLoading = false;
setState(() {});
if (url != null && url.contains("code=")) {
String code = url.split("?")[1].split("=")[1].split("&")[0];
Map params = Map();
params["client_id"] = AppApiConfig.CLIENT_ID;
params["client_secret"] = AppApiConfig.SECRET_KEY;
params["grant_type"] = "authorization_code";
params["redirect_uri"] = AppApiConfig.CALLBACK;
params["code"] = '$code';
params["dataType"] = "json";
NetUtils.post(AppUrls.OAUTH2_TOKEN, params).then((data) async {
Map map = json.decode(data);
// TODO: 处理bug错误
if (map["error"] == "400") {
print("请求出错");
return;
}
if (map != null && map.isNotEmpty) {
await DataUtils.setLoginInfo(map: map);
Navigator.pop(context, AppMsg.SUCCESS);
}
});
}
}
});
}

```
2. ...
3. ...

## Logs

![image](https://user-images.githubusercontent.com/46376536/102970272-2a94ac80-4532-11eb-85c0-08f30b5cd70e.png)

```
2 I/flutter (12981): url changed: http://blog.jackson615.top/?code=7rX7S6&state=
```

```
```

```
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the Android case using the initState listener on webviewPlugin.onUrlChanged and the logged callback URL. Trace where the monitoring event is emitted and verify that the same URL produces one callback rather than two; the issue is done when the duplicate notification no longer occurs.

Written by the indexing model from the issue text.

Assessment

Tech stack
flutter, java
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.