Learn's DelayedDeletions, unchanged, with its test, so that Train's workouts can be deleted with an undo as Learn's items are. Learn's deletions import it from halkyon_app now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
17 lines
578 B
Dart
17 lines
578 B
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
/// Waits until [condition] holds, checking every few milliseconds, and fails
|
|
/// after [timeout]: for what follows a real timer, without betting on how
|
|
/// fast a busy machine runs.
|
|
Future<void> eventually(
|
|
bool Function() condition, {
|
|
Duration timeout = const Duration(seconds: 10),
|
|
}) async {
|
|
final stopwatch = Stopwatch()..start();
|
|
while (!condition()) {
|
|
if (stopwatch.elapsed > timeout) {
|
|
fail('Still not so after $timeout.');
|
|
}
|
|
await Future<void>.delayed(const Duration(milliseconds: 10));
|
|
}
|
|
}
|