Skip to content
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

Feat: Add Support For 24 Hour Format In showTimePicker #162323

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

ArchishmanSengupta
Copy link

Summary:

Adds new parameter use24HourFormat in showTimePicker to display 24 Hour Time Format. Fixes #144919

Before:

showTimePicker(
  context: context,
  initialTime: TimeOfDay(hour: 22, minute: 0),
  builder: (context, child) {
    return MediaQuery(
      data: MediaQuery.of(
        context,
      ).copyWith(alwaysUse24HourFormat: true),
      child: child!,
    );
  },
);

After:

showTimePicker(
  use24HourFormat: true,
  context: context,
  initialTime: TimeOfDay(hour: 22, minute: 0),
 );

Pre-launch Checklist

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

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Jan 28, 2025
@Piinks Piinks requested a review from QuncCccccc January 29, 2025 19:33
@ArchishmanSengupta
Copy link
Author

@Piinks @QuncCccccc any updates on this?

@QuncCccccc
Copy link
Contributor

Sorry for the late response! I will take a look asap:)!

Copy link
Contributor

@QuncCccccc QuncCccccc left a comment

Choose a reason for hiding this comment

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

Thanks a lot for your patience! Overall this looks good to me:)

@ArchishmanSengupta
Copy link
Author

@QuncCccccc I've created a separate method to test the use24HourFormat and used it in the two test cases, this should avoid any confusion.

Please review and let me know if any other changes are required.

expect(find.text(pmString), findsNothing);

// When use24HourFormat: true, hours should be displayed in 24 hour format
final List<String> labels00To22 = List<String>.generate(12, (int index) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this call labels00To23?

Copy link
Author

Choose a reason for hiding this comment

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

here, we are multiplying indexes from 0 to 11 with 2, so it would be 00to22, right?

@piedcipher
Copy link
Member

piedcipher commented Feb 15, 2025

Linux Analyze check is failing due to 2 errors.

@dkwingsmt
Copy link
Contributor

It seems that multiple actual tests are failing. Can you take a look?

@ArchishmanSengupta
Copy link
Author

It seems that multiple actual tests are failing. Can you take a look?

Hey, I am working on this and will update you soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ability to select a 24-hour format as a parameter of showTimePicker
5 participants