Skip to content

CupertinoDatePicker - Non-selectable days are not greyed out. #136179

@ShaunByrne-UniSA

Description

@ShaunByrne-UniSA

Is there an existing issue for this?

Steps to reproduce

  1. Setup a CupertinoDatePicker with a minimum/maximum date.
  2. Observe the day text color of days that go out of the min/max date bounds.

Expected results

The day text color of non-selectable days should be greyed out like the month and year items so that the user knows which dates can be selected.

Actual results

The day text color of non-selectable days are the same as the selectable days. The only time a day is greyed out is when the month has less than 31 days.

Code sample

Code sample
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'Flutter Demo',
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  static Future<void> _showCupertinoDialog(BuildContext context, Widget child) {
    return showCupertinoModalPopup<void>(
      context: context,
      builder: (BuildContext context) => Container(
        height: 216,
        padding: const EdgeInsets.only(top: 6.0),
        margin: EdgeInsets.only(
          bottom: MediaQuery.of(context).viewInsets.bottom,
        ),
        color: CupertinoColors.systemBackground.resolveFrom(context),
        child: SafeArea(
          top: false,
          child: child,
        ),
      ),
    );
  }

  void _showDatePicker() {
    _showCupertinoDialog(
      context,
      CupertinoDatePicker(
        initialDateTime: DateTime(2023, 10, 9),
        minimumDate: DateTime(2023, 10, 9),
        maximumDate: DateTime(2023, 10, 9),
        dateOrder: DatePickerDateOrder.dmy,
        minimumYear: 2023,
        maximumYear: 2023,
        mode: CupertinoDatePickerMode.date,
        showDayOfWeek: true,
        onDateTimeChanged: (_) {},
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: const Center(
        child: Text(
          'Press + to show the date picker',
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _showDatePicker,
        tooltip: 'Date Picker',
        child: const Icon(Icons.calendar_today),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

Screenshot_1696829290

Logs

Logs
N/A

Flutter Doctor output

Doctor output
[√] Flutter (Channel master, 3.16.0-6.0.pre.5, on Microsoft Windows [Version 10.0.19045.3448], locale en-AU)
    • Flutter version 3.16.0-6.0.pre.5 on channel master at C:\dev\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision bf1cdb1596 (3 days ago), 2023-10-05 19:05:27 -0400
    • Engine revision 6492e1f8c3
    • Dart version 3.2.0 (build 3.2.0-231.0.dev)
    • DevTools version 2.28.1

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at C:\dev\android\sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = C:\dev\android\sdk
    • ANDROID_SDK_ROOT = C:\dev\android\sdk
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-10027231)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Enterprise 2022 17.4.5)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Enterprise
    • Visual Studio Enterprise 2022 version 17.4.33403.182
    • Windows 10 SDK version 10.0.22000.0

[√] Android Studio (version 2022.3)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-10027231)

[√] VS Code (version 1.83.0)
    • VS Code at C:\Users\byrnesd\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.74.0

[√] Connected device (4 available)
    • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64    • Android 14 (API 34) (emulator)
    • Windows (desktop)            • windows       • windows-x64    • Microsoft Windows [Version 10.0.19045.3448]
    • Chrome (web)                 • chrome        • web-javascript • Google Chrome 117.0.5938.134
    • Edge (web)                   • edge          • web-javascript • Microsoft Edge 115.0.1901.203

[√] Network resources
    • All expected network resources are available.

• No issues found!

Metadata

Metadata

Labels

P2Important issues not at the top of the work listf: cupertinoflutter/packages/flutter/cupertino repositoryf: date/time pickerDate or time picker widgetsfound in release: 3.13Found to occur in 3.13found in release: 3.16Found to occur in 3.16frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions