Skip to content

Time picker error in locales that do not use Latin digits - #186311

Closed
lamnhan066 wants to merge 11 commits into
flutter:masterfrom
lamnhan066:time-picker-error-in-some-locales
Closed

lamnhan066 wants to merge 11 commits into
flutter:masterfrom
lamnhan066:time-picker-error-in-some-locales

Conversation

@lamnhan066

Copy link
Copy Markdown
Contributor

The time picker currently uses int.parse and int.tryParse to parse the entered number. However, in some locales, numbers are not represented using Latin digits, which causes the parsing to fail. In this implementation, I use MaterialLocalizations to parse the number directly, ensuring that it works correctly for all locales.

Fixes #85527

A test has been added to ensure that the new implementation works as expected and does not cause any breaking changes.

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

@github-actions github-actions Bot added framework flutter/packages/flutter repository. See also f: labels. p: material_ui material_ui package in flutter/packages labels May 10, 2026
@lamnhan066
lamnhan066 force-pushed the time-picker-error-in-some-locales branch 2 times, most recently from 9791330 to 742608f Compare May 10, 2026 13:29
@lamnhan066
lamnhan066 marked this pull request as ready for review May 10, 2026 13:31

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

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.

Code Review

This pull request introduces localized number parsing for the time picker's text input fields. It adds logic to cache localized digit mappings, clear them on locale changes, and strip localized leading zeros. A new test suite verifies these changes across multiple locales. Feedback was provided to ensure the leading zero removal logic correctly handles multi-unit characters.

@lamnhan066 lamnhan066 changed the title Time picker error in some locales Time picker error in locales that do not use Latin digits May 10, 2026
@lamnhan066
lamnhan066 force-pushed the time-picker-error-in-some-locales branch 2 times, most recently from e9ee0f9 to 4e88fb9 Compare May 13, 2026 02:59
@dkwingsmt
dkwingsmt requested review from QuncCccccc and dkwingsmt and removed request for dkwingsmt May 13, 2026 18:15
@QuncCccccc QuncCccccc added the CICD Run CI/CD label May 14, 2026
@QuncCccccc
QuncCccccc force-pushed the time-picker-error-in-some-locales branch from 4e88fb9 to 717b2aa Compare May 14, 2026 17:42
@github-actions github-actions Bot removed the CICD Run CI/CD label May 14, 2026
@QuncCccccc QuncCccccc added the CICD Run CI/CD label May 14, 2026
@lamnhan066
lamnhan066 force-pushed the time-picker-error-in-some-locales branch from 717b2aa to 47c8ad3 Compare May 17, 2026 13:11
@github-actions github-actions Bot removed the CICD Run CI/CD label May 17, 2026
@lamnhan066

Copy link
Copy Markdown
Contributor Author

Hi @QuncCccccc

I understand that the Material and Cupertino libraries are currently code-frozen, but I would like to know what steps I should take next for this PR. Thank you.

@QuncCccccc

Copy link
Copy Markdown
Contributor

Thanks a lot for the contribution! I'll take a look soon and once we get enough approvals for this PR, we'll mark this PR draft. When material_ui package starts to accept contribution, we can create a new PR to move the change over there:)!

@QuncCccccc QuncCccccc left a comment

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.

Overall looks good to me! Just left a few comments. Thanks for the fix!

@override
void didChangeDependencies() {
super.didChangeDependencies();
final Locale locale = Localizations.localeOf(context);

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.

The cache is built by MaterialLocalizations. Should we check MaterialLocalizations instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I prefer keeping Localizations.localeOf since MaterialLocalizations lacks an equivalent method. We should also avoid using MaterialLocalizations type for caching comparisons because its equality isn't as reliable as Locale's (which can handles deprecated locales).

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 see! Thanks for the explanation! Overall it looks good! I'll take another look tomorrow!

@lamnhan066
lamnhan066 force-pushed the time-picker-error-in-some-locales branch from 47c8ad3 to f716746 Compare May 27, 2026 02:50
@dkwingsmt
dkwingsmt requested a review from QuncCccccc June 3, 2026 18:24
QuncCccccc
QuncCccccc previously approved these changes Jun 17, 2026

@QuncCccccc QuncCccccc left a comment

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.

LGTM! Thanks a lot for the fix and the test coverage. There seems some more discussion in the original issue about 24-hour input case. But I think that's a separate issue and the latin digits parsing issue described in the description has been fixed.

@QuncCccccc QuncCccccc added the CICD Run CI/CD label Jun 17, 2026
@QuncCccccc

Copy link
Copy Markdown
Contributor

To fix linux analyze, we might need to run dart format to reformat time_picker.dart and time_picker_test.dart.
Screenshot 2026-06-17 at 10 25 42 AM

@dkwingsmt
dkwingsmt requested a review from elliette June 17, 2026 18:22
@lamnhan066

Copy link
Copy Markdown
Contributor Author

I see that the unformatted part isn’t related to the PR. Should I rebase and run dart format to fix it too?

@elliette

Copy link
Copy Markdown
Member

I see that the unformatted part isn’t related to the PR. Should I rebase and run dart format to fix it too?

Yes, it's possible these files haven't been touched since the last formatter update. Rebasing and running dart format should fix it.

elliette
elliette previously approved these changes Jun 18, 2026
@lamnhan066
lamnhan066 force-pushed the time-picker-error-in-some-locales branch from ebb31ee to 8727263 Compare June 19, 2026 01:08
@github-actions github-actions Bot removed the CICD Run CI/CD label Jun 19, 2026
@lamnhan066
lamnhan066 dismissed stale reviews from elliette and QuncCccccc via 0594e16 June 19, 2026 01:18
@lamnhan066
lamnhan066 requested a review from elliette June 19, 2026 01:19
@elliette elliette added the CICD Run CI/CD label Jun 23, 2026
@elliette

Copy link
Copy Markdown
Member

Looks like Linux web_skwasm_tests_1 timed out, just triggered a re-run.

@Piinks Piinks added the Decoupling: Not ready to port yet Instructions will be provided when this is ready to move to flutter/packages. label Jun 24, 2026
@Piinks

Piinks commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

I've marked this PR as not ready to port to flutter/packages yet.
We'll provide instructions to move this change over to material_ui once it is ready to receive PRs. Thank you!

@QuncCccccc QuncCccccc left a comment

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.

re-LGTM!

@dkwingsmt
dkwingsmt marked this pull request as draft July 22, 2026 18:11
@dkwingsmt dkwingsmt added the waiting for code freeze This PR is waiting for a code freeze to resolve. label Jul 22, 2026
@dkwingsmt

Copy link
Copy Markdown
Contributor

If you would like to return to this, material_ui and cupertino_ui are now accepting contributions. :)
Guidance and instructions for easily porting over can be found in #188444. Thank you for the contribution and for waiting!

@dkwingsmt dkwingsmt added Decoupling: Port to flutter/packages This PR is ready to be ported to flutter/packages. We will provide instructions to do so. and removed Decoupling: Not ready to port yet Instructions will be provided when this is ready to move to flutter/packages. labels Sep 24, 2026
@lamnhan066

lamnhan066 commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Closing in favor of flutter/packages#13035 - ported to material_ui in flutter/packages per #188444 (Material/Cupertino freeze).

@lamnhan066 lamnhan066 closed this Sep 27, 2026
lamnhan066 added a commit to lamnhan066/packages that referenced this pull request Sep 29, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Oct 22, 2026
…tin digits (#13035)

Port of flutter/flutter#186311, fixes flutter/flutter#85527

The time picker currently uses `int.parse` and `int.tryParse` to parse the entered number. However, in some locales, numbers are not represented using Latin digits, which causes the parsing to fail. In this implementation, I use `MaterialLocalizations` to parse the number directly, ensuring that it works correctly for all locales.

A test has been added to ensure that the new implementation works as expected and does not cause any breaking changes.

## Pre-Review Checklist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD Decoupling: Port to flutter/packages This PR is ready to be ported to flutter/packages. We will provide instructions to do so. framework flutter/packages/flutter repository. See also f: labels. p: material_ui material_ui package in flutter/packages waiting for code freeze This PR is waiting for a code freeze to resolve.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TimePicker] Enter a valid time error in some locales

5 participants