Skip to content

showDatePicker has date format issues when DatePickerEntryMode.input is selected #62401

Closed
flutter/packages
#12608

Description

@figengungor

Steps to Reproduce

20200728_141801

  1. Call showDatePicker method and choose edit mode in dialog. (Tested with 'tr' locale)
  2. Try to change the TextField manually. It changes from dot(.) format to slashes(/). Then when you enter, you get invalid format error. If you delete them all, then you can only enter digits because you don't have control over keyboard.

Expected results:
What I expect from this feature(DatePickerEntryMode.input) is to be able to disable/enable it. If I can't disable it, I want to control it. I want to be able to specify date format, control keyboard etc.

Actual results:
As specified at step 2, when you try to change the TextField manually, It changes from dot(.) format to slashes(/). Then when you enter, you get invalid format error. If you delete them all, then you can only enter digits because you don't have control over keyboard.

Logs
[✓] Flutter (Channel stable, v1.17.5, on Mac OS X 10.15.5 19F101, locale en-TR)
    • Flutter version 1.17.5 at /Users/figengungor/Documents/development/flutter
    • Framework revision 8af6b2f038 (4 weeks ago), 2020-06-30 12:53:55 -0700
    • Engine revision ee76268252
    • Dart version 2.8.4

 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/figengungor/Library/Android/sdk
    • Platform android-29, build-tools 29.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.5, Build version 11E608c
    • CocoaPods version 1.8.4

[✓] Android Studio (version 4.0)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 47.1.2
    • Dart plugin version 193.7361
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[!] Connected device
    ! No devices available

! Doctor found issues in 1 category.

Activity

  1. TahaTesser commented on Jul 28, 2020

    @TahaTesser
    Contributor

    hI @figengungor
    Just reopened this issue #55535, it would have been fixed but i can reproduce
    Please follow up on that issue, I'm closing the current one as a duplicate.
    If you disagree, please write in the comments and I will reopen it.
    Thank you

  2. figengungor commented on Aug 26, 2020

    @figengungor
    Author

    Hey @TahaTesser Can you open this issue again, please?
    Leaving the reason here: #63372 (comment)

  3. darrenaustin commented on Aug 27, 2020

    @darrenaustin
    Contributor

    I see where the confusion was. There are two related issues here:

    I will reopen this bug to address the keyboard issue.

  4. darrenaustin commented on Aug 27, 2020

    @darrenaustin
    Contributor

    It would appear to be a problem with specific devices, as I don't see the problem on an Android Emulator (API 30):

    DateKeyboard

    Can you tell us what devices you are seeing this problem on?

  5. darrenaustin commented on Aug 27, 2020

    @darrenaustin
    Contributor

    We are requesting the InputType.TYPE_CLASS_DATETIME keyboard which one would think would include separators needed for entering a date and time for a given locale, but it appears that some devices just show the number entry keyboard.

    Couple of possible ways to address this:

    • Don't specify the type of keyboard and just let the system bring up the default keyboard.

      This is a the safest, but leads to a less than great user experience for most users, as most devices bring up a date time keyboard designed for date entry.

    • Special case certain devices that we know have this issue and just use the default keyboard for those.

      This is problematic in that we would be continually tracking these issues. And I think that it may be specific to whatever keyboard IME support the user has set up on their device.

    • Expose the keyboardType parameter in the showDatePicker/showDateRangePicker(), and InputDatePickerFormField that would allow apps to override with what ever keyboard request they want.

      We could do this independent of the the first two. It would allow the apps to override the default, but it would be nice if they didn't have to.

  6. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Aug 27, 2020
  7. lsarruda commented on Aug 29, 2020

    @lsarruda

    Hi,

    I'm having the same problem, the emulator works correctly, but on my phone the date (/) separator does not appear.

    Location pt - BR.

    Phone - Samsung Galaxy S20.

  8. darrenaustin commented on Aug 31, 2020

    @darrenaustin
    Contributor

    It certainly looks like this is mostly a problem with Samsung devices. However, given that it is apparently up to the keyboard installed by the user to decide what it wants to show for a InputType.TYPE_CLASS_DATETIME keyboard, it would probably be best to err on the conservative side and go with the full default keyboard for the date pickers and expose the keyboardType as a parameter so that apps can override this if they want.

    Opinions/feedback on this welcome.

  9. figengungor commented on Sep 1, 2020

    @figengungor
    Author

    I tested on Lg G5. This feature cannot be used on certain devices so in order to make it functional, the keyboardType can be exposed for now. We can think of better ways to do it later.

  10. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Sep 1, 2020
  11. 21 remaining items

  12. flutter-triage-bot commented on Nov 11, 2024

    @flutter-triage-bot

    This issue is missing a priority label. Please set a priority label when adding the triaged-design label.

  13. added
    triaged-designTriaged by Design Languages team
    P2Important issues not at the top of the work list
    on Nov 13, 2024
  14. ashiq-dev-codes commented on Aug 21, 2025

    @ashiq-dev-codes

    GitHub Issue / Suggestion: Standardizing showDatePicker Date Format

    Problem:
    Users can manually type dates in mm/dd/yyyy format while most of the app expects dd/MM/yyyy. This causes parsing errors and inconsistent date formats across the app.

    Proposed Solutions:


    1. Using Flutter Localization

    You can force the date picker to follow a locale that uses dd/MM/yyyy (e.g., UK or India) by using Flutter’s built-in localizations:

    // In pubspec.yaml, ensure flutter_localizations is added
    flutter_localizations:
      sdk: flutter
    
    // MaterialApp setup
    MaterialApp(
      title: 'APP NAME',
      localizationsDelegates: const [
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate,
      ],
      supportedLocales: const [
        Locale('en', 'GB'), // UK English = dd/MM/yyyy
        Locale('ar', 'AE'), // Arabic, UAE
        Locale('en', 'IN'), // Indian English = dd/MM/yyyy
      ],
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
    
    // DatePicker usage
    await showDatePicker(
      locale: const Locale('en', 'GB'), // or Locale('en', 'IN')
      context: context,
      fieldHintText: 'dd/MM/yyyy',
      initialDate: selectedDate,
      firstDate: DateTime(1970, 8),
      lastDate: DateTime(2101),
    );

    ✅ Pros: Works with stock showDatePicker.
    ⚠️ Cons: Requires adding flutter_localizations to pubspec.

    2. Using a Custom CalendarDelegate

    If you want to avoid adding localization dependencies or handle manual input parsing more flexibly, you can extend GregorianCalendarDelegate and override parseCompactDate:

    class CustomCalendarGregorianCalendarDelegate extends GregorianCalendarDelegate {
      const CustomCalendarGregorianCalendarDelegate();
    
      @override
      DateTime? parseCompactDate(String? inputString, MaterialLocalizations localizations) {
        if (inputString == null || inputString.isEmpty) return null;
    
        try {
          // First, try dd/MM/yyyy
          return DateFormat('dd/MM/yyyy').parseStrict(inputString);
        } catch (_) {
          try {
            // Fallback: MM/dd/yyyy
            return DateFormat('MM/dd/yyyy').parseStrict(inputString);
          } catch (_) {
            return null;
          }
        }
      }
    }

    Usage:

    await showDatePicker(
      context: context,
      fieldHintText: 'dd/MM/yyyy',
      initialDate: selectedDate,
      firstDate: DateTime(1970, 8),
      lastDate: DateTime(2101),
      calendarDelegate: CustomCalendarGregorianCalendarDelegate(),
    );

    ✅ Pros: Full control over manual input parsing, no extra pubspec assets required.
    ⚠️ Cons: Requires using a picker or widget that supports custom CalendarDelegate.

    Recommendation:


    • Use Flutter localization for a quick standard solution.
    • Use CustomCalendarGregorianCalendarDelegate for strict manual input handling or if flutter_localizations cannot be added.
  15. added
    packageflutter/packages repository. See also p: labels.
    and removed
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Aug 17, 2026
  16. added a commit that references this issue on Sep 10, 2026
    c437326
  17. github-actions commented on Sep 24, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  18. locked as resolved and limited conversation to collaborators on Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemscustomer: crowdAffects or could affect many people, though not necessarily a specific customer.f: date/time pickerDate or time picker widgetsp: material_uimaterial_ui package in flutter/packagespackageflutter/packages repository. See also p: labels.team-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions