Unverified Commit 4dd91363 authored by Darren Austin's avatar Darren Austin Committed by GitHub

Reset autovalidate in the text input form field of the Date Picker when...

Reset autovalidate in the text input form field of the Date Picker when switching back to input mode from calendar mode. (#53434)
parent 8ce6f05c
......@@ -296,6 +296,7 @@ class _DatePickerDialogState extends State<_DatePickerDialog> {
setState(() {
switch (_entryMode) {
case DatePickerEntryMode.calendar:
_autoValidate = false;
_entryMode = DatePickerEntryMode.input;
break;
case DatePickerEntryMode.input:
......
......@@ -136,6 +136,30 @@ void main() {
});
});
testWidgets('Switching to input mode resets input error state', (WidgetTester tester) async {
await prepareDatePicker(tester, (Future<DateTime> date) async {
// Enter text input mode and type an invalid date to get error.
await tester.tap(find.byIcon(Icons.edit));
await tester.pumpAndSettle();
await tester.enterText(find.byType(TextField), '1234567');
await tester.tap(find.text('OK'));
await tester.pumpAndSettle();
expect(find.text('Invalid format.'), findsOneWidget);
// Toggle to calender mode and then back to input mode
await tester.tap(find.byIcon(Icons.calendar_today));
await tester.pumpAndSettle();
await tester.tap(find.byIcon(Icons.edit));
await tester.pumpAndSettle();
expect(find.text('Invalid format.'), findsNothing);
// Edit the text, the error should not be showing until ok is tapped
await tester.enterText(find.byType(TextField), '1234567');
await tester.pumpAndSettle();
expect(find.text('Invalid format.'), findsNothing);
});
});
testWidgets('builder parameter', (WidgetTester tester) async {
Widget buildFrame(TextDirection textDirection) {
return MaterialApp(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment