你如何持续检查互联网访问?我能够显示是否已连接 wifi 或移动数据。但是,并非所有连接都可以访问 Internet。
import 'package:connectivity/connectivity.dart';
var connectivityResult = await (Connectivity().checkConnectivity());
if (connectivityResult == ConnectivityResult.mobile) {
// I am connected to a mobile network.
} else if (connectivityResult == ConnectivityResult.wifi) {
// I am connected to a wifi network.
}
Run Code Online (Sandbox Code Playgroud)
这是我目前使用的代码。我希望有人可以连续检查互联网访问?