initConnectivity method
Initializes connectivity and sets up listeners for changes
Implementation
Future<void> initConnectivity({
VoidCallback? onOnline,
VoidCallback? onOffline,
}) async {
// Check current connectivity status
List<ConnectivityResult> result = await Connectivity().checkConnectivity();
_isInternetConnected(result);
// Listen for changes in connectivity
Connectivity()
.onConnectivityChanged
.listen((List<ConnectivityResult>? result) {
if (kDebugMode) {
print(result);
}
_isInternetConnected(result);
});
}