data_connection_checker icon indicating copy to clipboard operation
data_connection_checker copied to clipboard

Disconnected status when the application is in the background

Open marcusgregory opened this issue 5 years ago • 5 comments

DataConnectionChecker().onStatusChange.listen always returns 'DataConnectionStatus.disconnected ' status when the application is in the background.

marcusgregory avatar Apr 02 '20 07:04 marcusgregory

Yes i agree with @marcusgregory, i'm also facing this issue.

prasantco avatar May 22 '20 08:05 prasantco

@marcusgregory I tried this in debug mode by putting app in the background (AppLifecycleState.paused) and then resuming it (AppLifecycleState.resumed). I did not see this issue. Can you elaborate on the use case you where you are seeing this issue?

aghanti7 avatar Jul 04 '20 04:07 aghanti7

@aghanti7 I'm using it this way in my application You can also check my repository

int onlineFlag = 0;
 StreamSubscription<DataConnectionStatus> listenConnection;
   listenConnection = DataConnectionChecker().onStatusChange.listen((status) {
      switch (status) {
        case DataConnectionStatus.connected:
          if (onlineFlag > 0) {
                    print('Now is online.');
          }
          break;
        case DataConnectionStatus.disconnected:
          onlineFlag++;
                  print('It is offline.');
          break;
      }
    });

marcusgregory avatar Jul 07 '20 00:07 marcusgregory

I've same issue, do you got any solution for this ? @marcusgregory

Kishan-Somaiya avatar May 26 '21 05:05 Kishan-Somaiya

Still no solution for this problem @Kishan-Somaiya.

marcusgregory avatar May 26 '21 14:05 marcusgregory