Refactoring - Version OK
This commit is contained in:
19
unionflow-mobile-apps/lib/core/network/network_info.dart
Normal file
19
unionflow-mobile-apps/lib/core/network/network_info.dart
Normal file
@@ -0,0 +1,19 @@
|
||||
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||
|
||||
/// Interface pour vérifier la connectivité réseau
|
||||
abstract class NetworkInfo {
|
||||
Future<bool> get isConnected;
|
||||
}
|
||||
|
||||
/// Implémentation de NetworkInfo utilisant connectivity_plus
|
||||
class NetworkInfoImpl implements NetworkInfo {
|
||||
final Connectivity connectivity;
|
||||
|
||||
NetworkInfoImpl(this.connectivity);
|
||||
|
||||
@override
|
||||
Future<bool> get isConnected async {
|
||||
final result = await connectivity.checkConnectivity();
|
||||
return result.any((r) => r != ConnectivityResult.none);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user