File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,3 +11,4 @@ export 'src/api_options/api_options.dart';
1111export 'src/interceptors/cache_interceptor.dart' ;
1212export 'src/interceptors/cancel_token_interceptor.dart' ;
1313export 'src/interceptors/refresh_token_interceptor.dart' ;
14+ export 'src/utils/network_checker.dart' ;
Original file line number Diff line number Diff line change 1+ import 'package:internet_connection_checker/internet_connection_checker.dart' ;
2+
3+ class NetworkConnectivityService {
4+ NetworkConnectivityService ._internal ()
5+ : connectionChecker = InternetConnectionChecker .createInstance (
6+ addresses: [
7+ AddressCheckOption (uri: Uri .parse ('https://www.google.com' )),
8+ AddressCheckOption (uri: Uri .parse ('https://www.bing.com' )),
9+ AddressCheckOption (uri: Uri .parse ('https://www.amazon.com' )),
10+ AddressCheckOption (uri: Uri .parse ('https://www.cloudflare.com' )),
11+ ],
12+ );
13+
14+ static NetworkConnectivityService ? _instance;
15+
16+ static NetworkConnectivityService get instance {
17+ _instance ?? = NetworkConnectivityService ._internal ();
18+ return _instance! ;
19+ }
20+
21+ final InternetConnectionChecker connectionChecker;
22+
23+ Future <bool > get isConnected => connectionChecker.hasConnection;
24+ }
You can’t perform that action at this time.
0 commit comments