onInit method

  1. @override
Future<void> onInit()
override

Called immediately after the widget is allocated in memory. You might use this to initialize something for the controller.

Implementation

@override
Future<void> onInit() async {
  // Check internet connection with singleton (no custom values allowed)
  listener = InternetConnectionChecker().onStatusChange.listen(
    (InternetConnectionStatus status) {
      switch (status) {
        case InternetConnectionStatus.connected:
          mirrorFlyLog("network", 'Data connection is available.');
          break;
        case InternetConnectionStatus.disconnected:
          mirrorFlyLog("network", 'You are disconnected from the internet.');
          break;
      }
    },
  );
  /*// Create customized instance which can be registered via dependency injection
  final InternetConnectionChecker customInstance =
  InternetConnectionChecker.createInstance(
    checkTimeout: const Duration(seconds: 1),
    checkInterval: const Duration(seconds: 1),

  );

  // Check internet connection with created instance
  await execute(customInstance);*/
  super.onInit();
}