Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
8aca65a9
Unverified
Commit
8aca65a9
authored
Mar 17, 2021
by
Shi-Hao Hong
Committed by
GitHub
Mar 17, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include validation for inputOnly mode (#78428)
parent
ec8fef65
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
2 deletions
+27
-2
date_picker.dart
packages/flutter/lib/src/material/date_picker.dart
+2
-2
date_picker_test.dart
packages/flutter/test/material/date_picker_test.dart
+11
-0
date_range_picker_test.dart
packages/flutter/test/material/date_range_picker_test.dart
+14
-0
No files found.
packages/flutter/lib/src/material/date_picker.dart
View file @
8aca65a9
...
...
@@ -306,7 +306,7 @@ class _DatePickerDialogState extends State<_DatePickerDialog> {
}
void
_handleOk
()
{
if
(
_entryMode
==
DatePickerEntryMode
.
input
)
{
if
(
_entryMode
==
DatePickerEntryMode
.
input
||
_entryMode
==
DatePickerEntryMode
.
inputOnly
)
{
final
FormState
form
=
_formKey
.
currentState
!;
if
(!
form
.
validate
())
{
setState
(()
=>
_autoValidate
=
true
);
...
...
@@ -972,7 +972,7 @@ class _DateRangePickerDialogState extends State<_DateRangePickerDialog> {
}
void
_handleOk
()
{
if
(
_entryMode
==
DatePickerEntryMode
.
input
)
{
if
(
_entryMode
==
DatePickerEntryMode
.
input
||
_entryMode
==
DatePickerEntryMode
.
inputOnly
)
{
final
_InputDateRangePickerState
picker
=
_inputPickerKey
.
currentState
!;
if
(!
picker
.
validate
())
{
setState
(()
{
...
...
packages/flutter/test/material/date_picker_test.dart
View file @
8aca65a9
...
...
@@ -177,6 +177,17 @@ void main() {
});
});
testWidgets
(
'Input only mode should validate date'
,
(
WidgetTester
tester
)
async
{
initialEntryMode
=
DatePickerEntryMode
.
inputOnly
;
await
prepareDatePicker
(
tester
,
(
Future
<
DateTime
?>
date
)
async
{
// Enter text input mode and type an invalid date to get error.
await
tester
.
enterText
(
find
.
byType
(
TextField
),
'1234567'
);
await
tester
.
tap
(
find
.
text
(
'OK'
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'Invalid format.'
),
findsOneWidget
);
});
});
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.
...
...
packages/flutter/test/material/date_range_picker_test.dart
View file @
8aca65a9
...
...
@@ -266,6 +266,20 @@ void main() {
});
});
testWidgets
(
'Input only mode should validate date'
,
(
WidgetTester
tester
)
async
{
initialEntryMode
=
DatePickerEntryMode
.
inputOnly
;
errorInvalidText
=
'oops'
;
await
preparePicker
(
tester
,
(
Future
<
DateTimeRange
?>
range
)
async
{
await
tester
.
enterText
(
find
.
byType
(
TextField
).
at
(
0
),
'08/08/2014'
);
await
tester
.
enterText
(
find
.
byType
(
TextField
).
at
(
1
),
'08/08/2014'
);
expect
(
find
.
text
(
errorInvalidText
!),
findsNothing
);
await
tester
.
tap
(
find
.
text
(
'OK'
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
errorInvalidText
!),
findsNWidgets
(
2
));
});
});
testWidgets
(
'Switching to input mode keeps selected date'
,
(
WidgetTester
tester
)
async
{
await
preparePicker
(
tester
,
(
Future
<
DateTimeRange
?>
range
)
async
{
await
tester
.
tap
(
find
.
text
(
'12'
).
first
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment