import 'dart:io';
void main() async{
try {
final result = await InternetAddress.lookup('example.com');
if (result.isNotEmpty && result[0].rawAddress.isNotEmpty) {
print('connected');
}
}on SocketException catch (_) {
print('not connected');
}
}
标签:dart,print,connected,result,网络连接,判定,isNotEmpty
From: https://www.cnblogs.com/sqmw/p/17053308.html