-
Notifications
You must be signed in to change notification settings - Fork 611
feat: add locale prop to CupertinoDatePicker, DatePicker, DateRangePicker, TimePicker
#6030
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Deploying flet-examples with
|
| Latest commit: |
bad59c1
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://d6d3aabb.flet-examples.pages.dev |
| Branch Preview URL: | https://improve-locales.flet-examples.pages.dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've reviewed this pull request using the Sourcery rules engine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request adds a locale property to CupertinoDatePicker, DatePicker, DateRangePicker, and TimePicker controls to address issue #6009, which reported that date pickers were not respecting the page locale setting.
Changes:
- Enhanced the
LocaleandLocaleConfigurationclasses with improved validation and detailed documentation - Added a
localeproperty to all four picker controls (DatePicker, DateRangePicker, TimePicker, CupertinoDatePicker) - Implemented Dart-side locale override functionality using
Localizations.override - Added comprehensive test coverage and example files demonstrating the new feature
Reviewed changes
Copilot reviewed 21 out of 27 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
sdk/python/packages/flet/src/flet/controls/types.py |
Enhanced Locale and LocaleConfiguration dataclasses with validation, default values, and comprehensive documentation |
sdk/python/packages/flet/src/flet/controls/material/time_picker.py |
Added locale property to TimePicker |
sdk/python/packages/flet/src/flet/controls/material/date_range_picker.py |
Added locale property to DateRangePicker |
sdk/python/packages/flet/src/flet/controls/material/date_picker.py |
Added locale property to DatePicker |
sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_date_picker.py |
Added locale property to CupertinoDatePicker |
packages/flet/lib/src/controls/*.dart |
Implemented locale override using Localizations.override wrapper |
packages/flet/lib/src/utils/locale.dart |
Added locale validation against Flutter's supported locales |
packages/flet/lib/src/utils/enums.dart |
Created reusable enum parsing utility |
packages/flet/lib/src/utils/misc.dart |
Refactored to use new parseEnum utility |
| Test files | Added locale-specific tests with golden image comparisons |
| Example files | Added custom_locale.py examples for each picker control |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Deploying flet-docs with
|
| Latest commit: |
bad59c1
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://9ff884ff.flet-docs.pages.dev |
| Branch Preview URL: | https://improve-locales.flet-docs.pages.dev |
Fixes this warning:
/Users/runner/work/flet/flet/sdk/python/packages/flet/src/flet/controls/control_event.py:82: DeprecationWarning: Failing to pass a value to the 'type_params' parameter of 'typing._eval_type' is deprecated, as it leads to incorrect behaviour when calling typing._eval_type on a stringified annotation that references a PEP 695 type parameter. It will be disallowed in Python 3.15.
event_type = _eval_type(event_type, globalns, localns)
# Conflicts: # sdk/python/packages/flet/src/flet/controls/control_event.py # sdk/python/packages/flet/src/flet/utils/from_dict.py
Fix #6009
Test Code
Summary by Sourcery
Add per-control locale overrides to date and time pickers and tighten locale configuration/validation across Flutter and Python layers.
New Features:
localeproperty for CupertinoDatePicker, DatePicker, DateRangePicker, and TimePicker controls to allow overriding page/system locale per picker instance.Enhancements:
LocaleandLocaleConfigurationtypes with stronger defaults, validation, and detailed documentation for language/region/script handling and resolution behaviour.Locale.isSupportedByDelegateshelper.parseEnumutility.Documentation:
Tests: