onInit method
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:
LogMessage.d("network", 'Data connection is available.');
break;
case InternetConnectionStatus.disconnected:
LogMessage.d("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();
}