mirror of
https://github.com/jonasbark/swiftcontrol.git
synced 2026-12-05 04:57:32 +01:00
flutter_foreground_task registers a BGTaskScheduler refresh task from its didFinishLaunching hook. With UIScene, Flutter forwards that hook from the scene's FlutterViewController, which can be after the app finished launching, and BGTaskScheduler then throws (App Store crash, 7.3.0, iPad on iOS 16.6.1). BikeControl only uses the package on Android, for the screen recording foreground service, and never declared the refresh task. The plugin is vendored at 9.2.2 under packages/flutter_foreground_task and now registers and schedules the refresh task only if the host Info.plist lists it in BGTaskSchedulerPermittedIdentifiers. 11.0.3 still registers unconditionally from didFinishLaunching, so upgrading would not fix it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
27 lines
649 B
Dart
27 lines
649 B
Dart
final class Utility {
|
|
Utility._();
|
|
|
|
static Utility instance = Utility._();
|
|
|
|
Future<bool> completedWithinDeadline({
|
|
required Duration deadline,
|
|
required Future<bool> Function() future,
|
|
Duration tick = const Duration(milliseconds: 100),
|
|
}) async {
|
|
final Stopwatch stopwatch = Stopwatch()..start();
|
|
bool completed = false;
|
|
await Future.doWhile(() async {
|
|
completed = await future();
|
|
if (completed ||
|
|
stopwatch.elapsedMilliseconds > deadline.inMilliseconds) {
|
|
return false;
|
|
} else {
|
|
await Future.delayed(tick);
|
|
return true;
|
|
}
|
|
});
|
|
|
|
return completed;
|
|
}
|
|
}
|