Skip to content

YearPickerState in calendar_date_picker is using dayOverlayColor instead of yearOverlayColor #130051

@CaioT

Description

@CaioT

Is there an existing issue for this?

Steps to reproduce

  1. Set a Theme with datePickerTheme set.
  2. Set the values:
dayOverlayColor: MaterialStateProperty.resolveWith((states) {
      if (states.contains(MaterialState.hovered)) {
        return Colors.blue;
      }
      return Colors.red;
    }),
yearOverlayColor: MaterialStateProperty.resolveWith((states) {
      if (states.contains(MaterialState.hovered)) {
        return Colors.blue;
      } else if (states.contains(MaterialState.selected)) {
        return Colors.yellow;
      }
      return Colors.red;
    }),
  1. See that when you launch the date picker using showDatePicker() the year is using the dayOverlayColor on hover.
void selectDate(context) async {
    DateTime? datePicked = (await showDatePicker(
        context: context,
        initialDate: selectedDate,
        firstDate: DateTime(2000),
        lastDate: DateTime(2100),
        initialEntryMode: DatePickerEntryMode.calendarOnly));
    if (datePicked != null) {
      setState(() {
        datePicked = DateUtils.dateOnly(datePicked!);
        selectedDate = datePicked!;
        widget.onDatePicked(selectedDate);
      });
    }
}
  1. You could also just look at the code: https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/material/calendar_date_picker.dart#L1194

Expected results

DatePicker should use the YearOverlayColor from the theme data, not the day.

Also, the hover states for years seems to be inverse what it is for days, which causes a very strange UX / UI that doesn't look good:
image

Actual results

Uses dayOverlay instead of yearOverlay, making it difficult to style them independently.

Code sample

It's your code: https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/material/calendar_date_picker.dart#L1194

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[√] Flutter (Channel stable, 3.10.5, on Microsoft Windows [Version 10.0.22621.1848], locale en-US)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.4.5)
[√] Android Studio (version 2022.1)
[√] Connected device (3 available)
[√] Network resources

• No issues found!

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listf: date/time pickerDate or time picker widgetsf: material designflutter/packages/flutter/material repository.found in release: 3.10Found to occur in 3.10found in release: 3.12Found to occur in 3.12frameworkflutter/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

Status

Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions