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
9dc9cf57
Unverified
Commit
9dc9cf57
authored
Feb 22, 2022
by
Kirolous Nashaat
Committed by
GitHub
Feb 22, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added optional parameter keyboardType to showDatePicker (#93439)
parent
0277a46b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
1 deletion
+27
-1
date_picker.dart
packages/flutter/lib/src/material/date_picker.dart
+9
-0
input_date_picker_form_field.dart
...lutter/lib/src/material/input_date_picker_form_field.dart
+7
-1
date_picker_test.dart
packages/flutter/test/material/date_picker_test.dart
+11
-0
No files found.
packages/flutter/lib/src/material/date_picker.dart
View file @
9dc9cf57
...
@@ -151,6 +151,7 @@ Future<DateTime?> showDatePicker({
...
@@ -151,6 +151,7 @@ Future<DateTime?> showDatePicker({
String
?
errorInvalidText
,
String
?
errorInvalidText
,
String
?
fieldHintText
,
String
?
fieldHintText
,
String
?
fieldLabelText
,
String
?
fieldLabelText
,
TextInputType
?
keyboardType
,
})
async
{
})
async
{
assert
(
context
!=
null
);
assert
(
context
!=
null
);
assert
(
initialDate
!=
null
);
assert
(
initialDate
!=
null
);
...
@@ -195,6 +196,7 @@ Future<DateTime?> showDatePicker({
...
@@ -195,6 +196,7 @@ Future<DateTime?> showDatePicker({
errorInvalidText:
errorInvalidText
,
errorInvalidText:
errorInvalidText
,
fieldHintText:
fieldHintText
,
fieldHintText:
fieldHintText
,
fieldLabelText:
fieldLabelText
,
fieldLabelText:
fieldLabelText
,
keyboardType:
keyboardType
,
);
);
if
(
textDirection
!=
null
)
{
if
(
textDirection
!=
null
)
{
...
@@ -249,6 +251,7 @@ class DatePickerDialog extends StatefulWidget {
...
@@ -249,6 +251,7 @@ class DatePickerDialog extends StatefulWidget {
this
.
errorInvalidText
,
this
.
errorInvalidText
,
this
.
fieldHintText
,
this
.
fieldHintText
,
this
.
fieldLabelText
,
this
.
fieldLabelText
,
this
.
keyboardType
,
this
.
restorationId
,
this
.
restorationId
,
})
:
assert
(
initialDate
!=
null
),
})
:
assert
(
initialDate
!=
null
),
assert
(
firstDate
!=
null
),
assert
(
firstDate
!=
null
),
...
@@ -334,6 +337,11 @@ class DatePickerDialog extends StatefulWidget {
...
@@ -334,6 +337,11 @@ class DatePickerDialog extends StatefulWidget {
/// string. For example, 'Month, Day, Year' for en_US.
/// string. For example, 'Month, Day, Year' for en_US.
final
String
?
fieldLabelText
;
final
String
?
fieldLabelText
;
/// The keyboard type of the [TextField].
///
/// If this is null, it will default to [TextInputType.datetime]
final
TextInputType
?
keyboardType
;
/// Restoration ID to save and restore the state of the [DatePickerDialog].
/// Restoration ID to save and restore the state of the [DatePickerDialog].
///
///
/// If it is non-null, the date picker will persist and restore the
/// If it is non-null, the date picker will persist and restore the
...
@@ -512,6 +520,7 @@ class _DatePickerDialogState extends State<DatePickerDialog> with RestorationMix
...
@@ -512,6 +520,7 @@ class _DatePickerDialogState extends State<DatePickerDialog> with RestorationMix
errorInvalidText:
widget
.
errorInvalidText
,
errorInvalidText:
widget
.
errorInvalidText
,
fieldHintText:
widget
.
fieldHintText
,
fieldHintText:
widget
.
fieldHintText
,
fieldLabelText:
widget
.
fieldLabelText
,
fieldLabelText:
widget
.
fieldLabelText
,
keyboardType:
widget
.
keyboardType
,
autofocus:
true
,
autofocus:
true
,
),
),
const
Spacer
(),
const
Spacer
(),
...
...
packages/flutter/lib/src/material/input_date_picker_form_field.dart
View file @
9dc9cf57
...
@@ -56,6 +56,7 @@ class InputDatePickerFormField extends StatefulWidget {
...
@@ -56,6 +56,7 @@ class InputDatePickerFormField extends StatefulWidget {
this
.
errorInvalidText
,
this
.
errorInvalidText
,
this
.
fieldHintText
,
this
.
fieldHintText
,
this
.
fieldLabelText
,
this
.
fieldLabelText
,
this
.
keyboardType
,
this
.
autofocus
=
false
,
this
.
autofocus
=
false
,
})
:
assert
(
firstDate
!=
null
),
})
:
assert
(
firstDate
!=
null
),
assert
(
lastDate
!=
null
),
assert
(
lastDate
!=
null
),
...
@@ -125,6 +126,11 @@ class InputDatePickerFormField extends StatefulWidget {
...
@@ -125,6 +126,11 @@ class InputDatePickerFormField extends StatefulWidget {
/// string. For example, 'Month, Day, Year' for en_US.
/// string. For example, 'Month, Day, Year' for en_US.
final
String
?
fieldLabelText
;
final
String
?
fieldLabelText
;
/// The keyboard type of the [TextField].
///
/// If this is null, it will default to [TextInputType.datetime]
final
TextInputType
?
keyboardType
;
/// {@macro flutter.widgets.editableText.autofocus}
/// {@macro flutter.widgets.editableText.autofocus}
final
bool
autofocus
;
final
bool
autofocus
;
...
@@ -242,7 +248,7 @@ class _InputDatePickerFormFieldState extends State<InputDatePickerFormField> {
...
@@ -242,7 +248,7 @@ class _InputDatePickerFormFieldState extends State<InputDatePickerFormField> {
labelText:
widget
.
fieldLabelText
??
localizations
.
dateInputLabel
,
labelText:
widget
.
fieldLabelText
??
localizations
.
dateInputLabel
,
),
),
validator:
_validateDate
,
validator:
_validateDate
,
keyboardType:
TextInputType
.
datetime
,
keyboardType:
widget
.
keyboardType
??
TextInputType
.
datetime
,
onSaved:
_handleSaved
,
onSaved:
_handleSaved
,
onFieldSubmitted:
_handleSubmitted
,
onFieldSubmitted:
_handleSubmitted
,
autofocus:
widget
.
autofocus
,
autofocus:
widget
.
autofocus
,
...
...
packages/flutter/test/material/date_picker_test.dart
View file @
9dc9cf57
...
@@ -26,6 +26,7 @@ void main() {
...
@@ -26,6 +26,7 @@ void main() {
String
?
fieldHintText
;
String
?
fieldHintText
;
String
?
fieldLabelText
;
String
?
fieldLabelText
;
String
?
helpText
;
String
?
helpText
;
TextInputType
?
keyboardType
;
final
Finder
nextMonthIcon
=
find
.
byWidgetPredicate
((
Widget
w
)
=>
w
is
IconButton
&&
(
w
.
tooltip
?.
startsWith
(
'Next month'
)
??
false
));
final
Finder
nextMonthIcon
=
find
.
byWidgetPredicate
((
Widget
w
)
=>
w
is
IconButton
&&
(
w
.
tooltip
?.
startsWith
(
'Next month'
)
??
false
));
final
Finder
previousMonthIcon
=
find
.
byWidgetPredicate
((
Widget
w
)
=>
w
is
IconButton
&&
(
w
.
tooltip
?.
startsWith
(
'Previous month'
)
??
false
));
final
Finder
previousMonthIcon
=
find
.
byWidgetPredicate
((
Widget
w
)
=>
w
is
IconButton
&&
(
w
.
tooltip
?.
startsWith
(
'Previous month'
)
??
false
));
...
@@ -52,6 +53,7 @@ void main() {
...
@@ -52,6 +53,7 @@ void main() {
fieldHintText
=
null
;
fieldHintText
=
null
;
fieldLabelText
=
null
;
fieldLabelText
=
null
;
helpText
=
null
;
helpText
=
null
;
keyboardType
=
null
;
});
});
Future
<
void
>
prepareDatePicker
(
Future
<
void
>
prepareDatePicker
(
...
@@ -94,6 +96,7 @@ void main() {
...
@@ -94,6 +96,7 @@ void main() {
fieldHintText:
fieldHintText
,
fieldHintText:
fieldHintText
,
fieldLabelText:
fieldLabelText
,
fieldLabelText:
fieldLabelText
,
helpText:
helpText
,
helpText:
helpText
,
keyboardType:
keyboardType
,
builder:
(
BuildContext
context
,
Widget
?
child
)
{
builder:
(
BuildContext
context
,
Widget
?
child
)
{
return
Directionality
(
return
Directionality
(
textDirection:
textDirection
,
textDirection:
textDirection
,
...
@@ -701,6 +704,14 @@ void main() {
...
@@ -701,6 +704,14 @@ void main() {
});
});
});
});
testWidgets
(
'KeyboardType is used'
,
(
WidgetTester
tester
)
async
{
keyboardType
=
TextInputType
.
text
;
await
prepareDatePicker
(
tester
,
(
Future
<
DateTime
?>
date
)
async
{
final
TextField
field
=
textField
(
tester
);
expect
(
field
.
keyboardType
,
TextInputType
.
text
);
});
});
testWidgets
(
'Initial date is the default'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Initial date is the default'
,
(
WidgetTester
tester
)
async
{
await
prepareDatePicker
(
tester
,
(
Future
<
DateTime
?>
date
)
async
{
await
prepareDatePicker
(
tester
,
(
Future
<
DateTime
?>
date
)
async
{
await
tester
.
tap
(
find
.
text
(
'OK'
));
await
tester
.
tap
(
find
.
text
(
'OK'
));
...
...
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