|
|
@@ -31,6 +31,16 @@ class InternetConnectionHelper {
|
|
|
|
|
|
final wifiInfo = NetworkInfo();
|
|
|
|
|
|
+ final customChecker = InternetConnectionChecker.createInstance(
|
|
|
+ checkInterval: Duration(seconds: 10),
|
|
|
+ addresses: [
|
|
|
+ AddressCheckOption(uri: Uri.parse('https://www.baidu.com')),
|
|
|
+ AddressCheckOption(uri: Uri.parse('https://www.qq.com')),
|
|
|
+ AddressCheckOption(uri: Uri.parse('https://www.aliyun.com')),
|
|
|
+ AddressCheckOption(uri: Uri.parse('https://www.163.com')),
|
|
|
+ ],
|
|
|
+ );
|
|
|
+
|
|
|
static InternetConnectionHelper getInstance() {
|
|
|
return getIt<InternetConnectionHelper>();
|
|
|
}
|
|
|
@@ -52,7 +62,7 @@ class InternetConnectionHelper {
|
|
|
|
|
|
/// 当前网络是否可用
|
|
|
Future<bool> isConnected() {
|
|
|
- return InternetConnectionChecker.instance.hasConnection;
|
|
|
+ return customChecker.hasConnection;
|
|
|
}
|
|
|
|
|
|
void startListenNetwork() {
|
|
|
@@ -120,8 +130,7 @@ class InternetConnectionHelper {
|
|
|
|
|
|
void startInternetConnection() {
|
|
|
_connectSubscription?.cancel();
|
|
|
- _connectSubscription =
|
|
|
- InternetConnectionChecker.instance.onStatusChange.listen(
|
|
|
+ _connectSubscription = customChecker.onStatusChange.listen(
|
|
|
(InternetConnectionStatus status) {
|
|
|
AtmobLog.d(tag, '网络连接情况:$status');
|
|
|
if (status == InternetConnectionStatus.connected ||
|