startNetworkListen method

void startNetworkListen()

Implementation

void startNetworkListen() {
  final InternetConnectionChecker customInstance =
      InternetConnectionChecker.createInstance(
    checkTimeout: const Duration(seconds: 1),
    checkInterval: const Duration(seconds: 1),
  );
  listener = customInstance.onStatusChange.listen(
    (InternetConnectionStatus status) {
      switch (status) {
        case InternetConnectionStatus.connected:
          mirrorFlyLog("network", 'Data connection is available.');
          networkConnected();
          if (Get.isRegistered<ChatController>()) {
            Get.find<ChatController>().networkConnected();
          }
          if (Get.isRegistered<ChatInfoController>()) {
            Get.find<ChatInfoController>().networkConnected();
          }
          /*if (Get.isRegistered<ContactSyncController>()) {
            Get.find<ContactSyncController>().networkConnected();
          }*/
          break;
        case InternetConnectionStatus.disconnected:
          mirrorFlyLog("network", 'You are disconnected from the internet.');
          networkDisconnected();
          if (Get.isRegistered<ChatController>()) {
            Get.find<ChatController>().networkDisconnected();
          }
          if (Get.isRegistered<ChatInfoController>()) {
            Get.find<ChatInfoController>().networkDisconnected();
          }
          /*if (Get.isRegistered<ContactSyncController>()) {
            Get.find<ContactSyncController>().networkDisconnected();
          }*/
          break;
      }
    },
  );
}