mirror of
https://github.com/wger-project/flutter.git
synced 2026-12-06 07:54:02 +01:00
Replace the allowed connectivity list
We now just test if there is obviously no connection, keeping an explicit list is brittle and would break if the plugin reported something non-obvious like "vpn"
This commit is contained in:
1 parent
60cf1b97e8
commit
e99a0363b9
1 file changed
+5
-7
@@ -48,12 +48,6 @@ Future<bool> _defaultReachabilityCheck(Duration timeout) async {
|
||||
class NetworkStatus extends _$NetworkStatus {
|
||||
final _logger = Logger('NetworkStatus');
|
||||
|
||||
static const allowed = {
|
||||
ConnectivityResult.mobile,
|
||||
ConnectivityResult.wifi,
|
||||
ConnectivityResult.ethernet,
|
||||
};
|
||||
|
||||
StreamSubscription<List<ConnectivityResult>>? _sub;
|
||||
|
||||
@override
|
||||
@@ -88,7 +82,11 @@ class NetworkStatus extends _$NetworkStatus {
|
||||
List<ConnectivityResult> conn, {
|
||||
Duration timeout = const Duration(seconds: 1),
|
||||
}) async {
|
||||
if (!conn.any((c) => allowed.contains(c))) {
|
||||
// Only short-circuit when there's clearly no network adapter at all. Any
|
||||
// other connectivity type (wifi, ethernet, mobile, vpn, other, ...) still
|
||||
// has to prove real reachability via the DNS check below. An empty list
|
||||
// counts as "no connection" too.
|
||||
if (conn.every((c) => c == ConnectivityResult.none)) {
|
||||
return false;
|
||||
}
|
||||
return reachabilityCheck(timeout);
|
||||
|
||||
Reference in new issue
Block a user