Skip to content

Date picker support input formatters#184283

Open
lrauseo wants to merge 8 commits intoflutter:masterfrom
lrauseo:date-picker-support-input-formatters
Open

Date picker support input formatters#184283
lrauseo wants to merge 8 commits intoflutter:masterfrom
lrauseo:date-picker-support-input-formatters

Conversation

@lrauseo
Copy link
Copy Markdown

@lrauseo lrauseo commented Mar 28, 2026

This PR includes inputFormatters in the date picker, allowing you to create textFormatters for the TextField used in InputDatePickerFormField, showDatePicker, and showDateRangePicker.

The purpose of this change is to enable input formatting within the DatePicker when it is in DatePickerEntryMode.input.

Fixes #83302
Fixes #97134
Fixes #62401
Fixes #181043
Fixes #115151

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos labels Mar 28, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the inputFormatters parameter to showDatePicker, showDateRangePicker, and their associated dialogs and form fields. This allows developers to provide a list of TextInputFormatter objects to control and format user input during manual date entry. The changes include updates to DatePickerDialog, DateRangePickerDialog, and InputDatePickerFormField to propagate these formatters to the underlying text fields. Additionally, a new code sample and unit tests have been added to demonstrate and verify the functionality. I have no feedback to provide.

Copy link
Copy Markdown
Contributor

@nate-thegrate nate-thegrate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for putting this together! I just have a few suggestions regarding documentation.

I don't really have an opinion about whether to move forward with this PR or with #181105, so I'll defer to other reviewers for an approval.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love the interactive code sample! But it doesn't look like it's being used anywhere. Consider adding it to our documentation somewhere; here's an example:

/// {@tool dartpad}
/// This sample demonstrates how to create a basic date picker.
/// Tapping the button displays a date picker which returns the selected date.
///
/// ** See code in examples/api/lib/material/date_picker/show_date_picker.1.dart **
/// {@end-tool}

lrauseo and others added 2 commits March 28, 2026 16:25
Co-authored-by: Nate Wilson <nathan.wilson1232@gmail.com>
Co-authored-by: Nate Wilson <nathan.wilson1232@gmail.com>
@lrauseo
Copy link
Copy Markdown
Author

lrauseo commented Mar 28, 2026

@nate-thegrate
Thank you for your suggestions.
In my analysis, #181105 had a very complex approach regarding providing formatting options in the date picker in input mode, creating a new delegate to format the dates. I thought about using input formatters because it's a simple and common pattern with TextFields.
But it seems that the PR #181105 has been refactored to follow the same approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

2 participants