Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
[connectivity] Clear networkCallback object as soon as stream is canc…
Browse files Browse the repository at this point in the history
…elled (#3303)

Set networkCallback back to null when event stream is cancelled
  • Loading branch information
ened authored Dec 18, 2020
1 parent 73eeb30 commit b6af039
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/connectivity/connectivity/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 3.0.0-nullsafety.2

* Android: Cleanup the NetworkCallback object when a connectivity stream is cancelled

## 3.0.0-nullsafety.1

* Bump Dart SDK to support null safety.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public void onCancel(Object arguments) {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
if (networkCallback != null) {
connectivity.getConnectivityManager().unregisterNetworkCallback(networkCallback);
networkCallback = null;
}
} else {
context.unregisterReceiver(this);
Expand Down
2 changes: 1 addition & 1 deletion packages/connectivity/connectivity/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: connectivity
description: Flutter plugin for discovering the state of the network (WiFi &
mobile/cellular) connectivity on Android and iOS.
homepage: https://github.com/flutter/plugins/tree/master/packages/connectivity/connectivity
version: 3.0.0-nullsafety.1
version: 3.0.0-nullsafety.2

flutter:
plugin:
Expand Down

0 comments on commit b6af039

Please sign in to comment.