mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-01-23 09:16:19 +01:00
d72f64d4f4
It doesn't work at all on web
19 lines
604 B
Dart
19 lines
604 B
Dart
import 'package:connectivity_plus/connectivity_plus.dart';
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:nc_photos/platform/k.dart' as platform_k;
|
|
|
|
Future<void> waitUntilWifi({VoidCallback? onNoWifi}) async {
|
|
if (platform_k.isWeb) {
|
|
// connectivity does NOT work on web, currently it will always return mobile
|
|
// on Blink, and none on Gecko
|
|
return;
|
|
}
|
|
while (true) {
|
|
final result = await Connectivity().checkConnectivity();
|
|
if (result == ConnectivityResult.wifi) {
|
|
return;
|
|
}
|
|
onNoWifi?.call();
|
|
await Future.delayed(const Duration(seconds: 5));
|
|
}
|
|
}
|