E/flutter ( 2631): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type 'List' is not a subtype of type 'ConnectivityResult' in type cast E/flutter ( 2631): #0
_MyAppState._checkInitialConnection (package:mark_v3/main.dart:126:51) E/flutter ( 2631):
Future<void> _checkInitialConnection() async {
final ConnectivityResult result =
(await _connectivity.checkConnectivity()) as ConnectivityResult;
_updateConnectionStatus([result]);
}
i think you are using the old approach in which
await _connectivity.checkConnectivity()
returned a ConnectivityResult now it returns a list of connectivity results
// Check the initial connection status
Future<void> _checkConnection() async {
// Since checkConnectivity() now returns a List<ConnectivityResult>
List<ConnectivityResult> results = await _connectivity.checkConnectivity();
// For simplicity, you can check the first result or handle all results
if (results.isNotEmpty) {
_updateConnectionStatus(results.first); // Use the first result for now
}
}
check the connectivity plus package here: pub.dev