I want to select a specific date of birth on the calendar but, firstly I have to assert which date is now, and then tap in the loop until the particular month (September) on the calendar is visible. The challenge is I cannot use expect(actual, matcher) as a condition in the loop because it does not store value true or false.
My idea was something like this
static selectMonth(WidgetTester tester) async {
final now = DateTime.now();
final september = find.text('September');
var month = expect(september, findsOneWidget);
if (now.month < 9) {
while (month == true) {
await ScreenTest.tapChevronRightIcon(tester);
}
await ScreenTest.tapDay(
tester,
dayOfBirth,
);
} else if (now.month > 9) {
while (month == true) {
await ScreenTest.tapChevronLeftIcon(tester);
}
await ScreenTest.tapDay(
tester,
dayOfBirth,
);
} else {
await ScreenTest.tapDay(
tester,
dayOfBirth,
);
}
}