Skip to content

Conversation

@ndonkoHenri
Copy link
Contributor

@ndonkoHenri ndonkoHenri commented Jan 18, 2026

Fix #6009

Test Code

import flet as ft


def main(page: ft.Page):
    page.horizontal_alignment = ft.CrossAxisAlignment.CENTER

    page.add(
        ft.Button(
            content="Pick time (zh_Hans locale)",
            icon=ft.Icons.CALENDAR_MONTH,
            on_click=lambda e: page.show_dialog(
                ft.TimePicker(locale=ft.Locale("zh", "Hans"))
            ),
        )
    )


ft.run(main)

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:

  • Introduce an optional locale property for CupertinoDatePicker, DatePicker, DateRangePicker, and TimePicker controls to allow overriding page/system locale per picker instance.

Enhancements:

  • Refine Python Locale and LocaleConfiguration types with stronger defaults, validation, and detailed documentation for language/region/script handling and resolution behaviour.
  • Filter supported locales on the Flutter side to only include those supported by Flutter localization delegates and add a Locale.isSupportedByDelegates helper.
  • Refactor multiple Dart enum parsing helpers to share a common generic parseEnum utility.
  • Export the new Dart enums utility module for broader reuse.

Documentation:

  • Add example apps demonstrating custom locales for CupertinoDatePicker, DatePicker, DateRangePicker, and TimePicker.

Tests:

  • Extend and restructure integration tests for CupertinoDatePicker, DatePicker, DateRangePicker, and TimePicker to cover locale overrides via screenshots and per-test app fixtures.

@ndonkoHenri ndonkoHenri requested a review from Copilot January 18, 2026 12:04
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 18, 2026

Deploying flet-examples with  Cloudflare Pages  Cloudflare Pages

Latest commit: bad59c1
Status: ✅  Deploy successful!
Preview URL: https://d6d3aabb.flet-examples.pages.dev
Branch Preview URL: https://improve-locales.flet-examples.pages.dev

View logs

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a 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

Copy link
Contributor

Copilot AI left a 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 Locale and LocaleConfiguration classes with improved validation and detailed documentation
  • Added a locale property 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.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 18, 2026

Deploying flet-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: bad59c1
Status: ✅  Deploy successful!
Preview URL: https://9ff884ff.flet-docs.pages.dev
Branch Preview URL: https://improve-locales.flet-docs.pages.dev

View logs

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
@FeodorFitsner FeodorFitsner merged commit aaa801c into main Jan 21, 2026
28 of 43 checks passed
@FeodorFitsner FeodorFitsner deleted the improve-locales branch January 21, 2026 03:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve locale documentation

3 participants