main
1import 'package:flutter_test/flutter_test.dart';
2
3extension WaitUntil on WidgetTester {
4 /// Retries with 100ms delay for up to [maxLength] for a [test] to succeed.
5 ///
6 /// When no value is provided [maxLength] defaults to 5s.
7 Future<void> pumpUntil(bool Function() test, [Duration? maxLength]) async {
8 maxLength ??= Duration(seconds: 5);
9
10 int retries = maxLength.inMilliseconds ~/ 100;
11 while(!test() && retries >= 0) {
12 retries--;
13 await pump(Duration(milliseconds: 100));
14 }
15 await pump();
16 }
17}