Skip to content

Multiple Connectivity instances breaks onConnectivityChanged #21709

@kibantony

Description

@kibantony

Using the connectivity plugin, if one creates multiple Connectivity() objects and listens to onConnectivityChanged, only one instance will receive events via the onConnectivityChanged stream.

Steps to Reproduce

  1. Run this app on a real iOS or Android device: https://gist.github.com/kibantony/7208a3feb786f5e41ecdb9fc5581d345
  2. With the app running, swipe up/down (depending on the platform) to bring up the OS shortcuts and turn off the network (Airplane mode).
  3. Return to the app and notice that only one of the Connectivity Status lines was updated.

image

Logs

Notice in the logs that onConnectivityChanged is only called for Connectivity instance B.

I/flutter ( 5122): A checkConnectivity: ConnectivityResult.wifi
I/flutter ( 5122): B onConnectivityChanged: ConnectivityResult.wifi
I/flutter ( 5122): B checkConnectivity: ConnectivityResult.wifi
I/flutter ( 5122): B onConnectivityChanged: ConnectivityResult.wifi
I/flutter ( 5122): B onConnectivityChanged: ConnectivityResult.none

Flutter Doctor

[✓] Flutter (Channel beta, v0.7.3, on Mac OS X 10.13.6 17G65, locale en-US)
    • Flutter version 0.7.3 at /Users/tony/afero/flutter
    • Framework revision 3b309bda07 (2 weeks ago), 2018-08-28 12:39:24 -0700
    • Engine revision af42b6dc95
    • Dart version 2.1.0-dev.1.0.flutter-ccb16f7282

[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
    • Android SDK at /Users/tony/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-27, build-tools 27.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
    • All Android licenses accepted.

[✓] iOS toolchain - develop for iOS devices (Xcode 9.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 9.4.1, Build version 9F2000
    • ios-deploy 1.9.2
    • CocoaPods version 1.5.3

[✓] Android Studio (version 3.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 27.1.1
    • Dart plugin version 173.4700
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)

[✓] VS Code (version 1.27.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 2.18.0

[✓] Connected devices (2 available)
    • SAMSUNG SM G925A • 02157df24a2a2e0a                     • android-arm64 • Android 6.0.1 (API 23)
    • iPhone 8         • EEF6AF6E-7CBB-464D-9115-131D04A6A5B6 • ios           • iOS 11.4 (simulator)

• No issues found!

Metadata

Metadata

Assignees

Labels

p: connectivityThe connectivity pluginpackageflutter/packages repository. See also p: labels.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions