nc-photos/lib/connectivity_util.dart

14 lines
388 B
Dart
Raw Normal View History

import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:flutter/foundation.dart';
2021-04-10 06:28:12 +02:00
Future<void> waitUntilWifi({VoidCallback? onNoWifi}) async {
2021-04-10 06:28:12 +02:00
while (true) {
final result = await Connectivity().checkConnectivity();
if (result == ConnectivityResult.wifi) {
return;
}
onNoWifi?.call();
2021-04-10 06:28:12 +02:00
await Future.delayed(const Duration(seconds: 5));
}
}