Repository navigation
[material_ui] Support custom date input formatters via CalendarDelegate - #12608
auto-submit[bot] merged 20 commits into
Conversation
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request adds support for customizing date input formatters in the Material date picker via CalendarDelegate.keyboardInputFormatters, along with a new API sample and tests. Review feedback identifies critical compilation errors in the example code regarding unsupported enum shorthand and the use of a non-existent initialValue parameter in DropdownButtonFormField. Additionally, the feedback points out an incorrect import path in the test file, redundant inputFormatters parameters in the date picker APIs, and a potential RangeError when handling negative selection offsets in DateInputFormatter.
… example and tests
QuncCccccc
left a comment
There was a problem hiding this comment.
Hi @Mairramer! Thanks for the contribution! Because of the volume of PRs we receive, it is a bit confusing to figure out which drafts are ready for review and which are not. So please convert the draft to ready-to-review status when it is ready so we will proceed the next step. I know there is a max limit for PR creation but let's do them one by one:) Thanks!
There was a problem hiding this comment.
Code Review
This pull request adds support for customizing date input formatters in the Material date picker via CalendarDelegate.keyboardInputFormatters. It updates CalendarDelegate to include this method, integrates it into the date range and form field pickers, and adds a comprehensive example and tests. The review comments point out critical issues in the new example code, including invalid leading dot syntax for enum initialization, incorrect parameter usage (initialValue instead of value) in DropdownButtonFormField, and a potential RangeError in DateInputFormatter when the selection offset is negative.
| int digitsBefore = _countDigits( | ||
| newValue.text.substring(0, newValue.selection.baseOffset), | ||
| ); |
There was a problem hiding this comment.
If newValue.selection.baseOffset is -1 (e.g., when the field is not focused or selection is invalid), calling substring(0, -1) will throw a RangeError. Guard against negative offsets before calling substring.
| int digitsBefore = _countDigits( | |
| newValue.text.substring(0, newValue.selection.baseOffset), | |
| ); | |
| final int baseOffset = newValue.selection.baseOffset; | |
| final int digitsBefore = baseOffset < 0 | |
| ? 0 | |
| : _countDigits(newValue.text.substring(0, baseOffset)); |
QuncCccccc
left a comment
There was a problem hiding this comment.
RS-LGTM since the original PR has been approved!
…r#192630) flutter/packages@8a35b16...9caa77c 2026-09-11 [email protected] [pigeon] main actor async flutter api (flutter/packages#12729) 2026-09-10 [email protected] [image_picker] Handle a null stream from openInputStream (flutter/packages#12718) 2026-09-10 [email protected] [material_ui] 1.2.0 sync back clean up (flutter/packages#12829) 2026-09-10 [email protected] [material_ui] Support custom date input formatters via CalendarDelegate (flutter/packages#12608) 2026-09-10 [email protected] [in_app_purchase_storekit] Expose expiration date directly for subscriptions (flutter/packages#11551) 2026-09-10 [email protected] [file_selector_android] Handle a null stream from openInputStream (flutter/packages#12716) 2026-09-10 [email protected] [pigeon] Add FFI and JNI support to Swift and Kotlin (flutter/packages#11352) 2026-09-10 [email protected] [material_ui] Migrate M3 Card defaults to new gen_defaults (flutter/packages#12795) If this roll has caused a breakage, revert this CL and set the roller to dry run mode using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC [email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
This PR adds the
keyboardInputFormattersmethod toCalendarDelegate.Previously, date input was strictly coupled to
MaterialLocalizations. This change allows developers to provide a list ofTextInputFormatters via a customCalendarDelegateto enforce specific input masks (e.g., dd/MM/yyyy) or restrict character entry in date pickers (showDatePicker,showDateRangePicker, andInputDatePickerFormField).Fixes flutter/flutter#83302
Fixes flutter/flutter#97134
Fixes flutter/flutter#62401
Fixes flutter/flutter#181043
Fixes flutter/flutter#115151
Fixes flutter/flutter#191639
Fixes partially flutter/flutter#150611
Port of flutter/flutter#181105
Pre-Review Checklist
[shared_preferences]///).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-assistbot 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.Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2