Skip to content

DatePickerThemeData's rangePickerHeaderBackgroundColor not being applied to DateRangePickerDialog on M2 #147301

Closed

Description

@LuisMiguelSS

Steps to reproduce

  1. Create an example app (or run in your current one, using Material 2)
  2. Set the property rangePickerHeaderBackgroundColor in your ThemeData > datePickerTheme to whichever color you prefer (i.e. Colors.green)
  3. Include a DateRangePickerDialog in your build(...) method or launch one via showDateRangePicker(...)

Expected results

The header's background of the DateRangePickerDialog is set to the specified color (green, in this case).

Actual results

The header's background of the DateRangePickerDialog is set to the ThemeData's appBarTheme backgroundColor`.

Although sometimes one would like this header to have the same color, not every time it's what is wanted.

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});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        useMaterial3: false,
        datePickerTheme: Theme.of(context).datePickerTheme.copyWith(
          //headerBackgroundColor: Colors.green, // <- This works for the DatePickerDialog
          rangePickerHeaderBackgroundColor: Colors.green, // <- This is NOT working for the DateRangePickerDialog
        )
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

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

class _MyHomePageState extends State<MyHomePage> {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: const Text("Example"),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Flexible(
                child: DateRangePickerDialog(
                    firstDate: DateTime(2000),
                    lastDate: DateTime(2200)
                )
            )
          ],
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

image

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.19.4, on macOS 14.2.1 23C71 darwin-arm64, locale en-US)
    • Flutter version 3.19.4 on channel stable at /opt/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 68bfaea224 (5 weeks ago), 2024-03-20 15:36:31 -0700
    • Engine revision a5c24f538d
    • Dart version 3.3.2
    • DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/{redacted}/Library/Android/sdk
    • Platform android-34-ext8, build-tools 34.0.0
    • ANDROID_HOME = /Users/{redacted}/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15E204a
    • CocoaPods version 1.13.0

[✓] Android Studio (version 2023.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • 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.9+0-17.0.9b1087.7-11185874)

[✓] Connected device (2 available)
    • {redacted}
    • {redacted}

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

• No issues found!

No difference found at 3.19.6

Activity

  1. added
    in triagePresently being triaged by the triage team
    on Apr 25, 2024
  2. huycozy commented on Apr 25, 2024

    @huycozy
    Member

    Hi @LuisMiguelSS
    I think this is WAI, please see:

    backgroundColor: useMaterial3 ? headerBackground : null,

    Even though migrating to Material 3 is recommended, I will keep this issue open for other's input.

    flutter doctor -v (stable and master)
    [✓] Flutter (Channel stable, 3.19.6, on macOS 14.1 23B74 darwin-x64, locale en-VN)
        • Flutter version 3.19.6 on channel stable at /Users/huynq/Documents/GitHub/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 54e66469a9 (31 hours ago), 2024-04-17 13:08:03 -0700
        • Engine revision c4cd48e186
        • Dart version 3.3.4
        • DevTools version 2.31.1
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
        • Android SDK at /Users/huynq/Library/Android/sdk
        • Platform android-34, build-tools 34.0.0
        • ANDROID_HOME = /Users/huynq/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 15.3)
        • Xcode at /Applications/Xcode15.3.app/Contents/Developer
        • Build 15E204a
        • CocoaPods version 1.15.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2023.2)
        • Android Studio at /Applications/Android Studio.app/Contents
        • 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
        • android-studio-dir = /Applications/Android Studio.app/
        • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
    
    [✓] VS Code (version 1.88.1)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.86.0
    
    [✓] Connected device (3 available)
        • RMX2001 (mobile) • EUYTFEUSQSRGDA6D • android-arm64  • Android 11 (API 30)
        • macOS (desktop)  • macos            • darwin-x64     • macOS 14.1 23B74 darwin-x64
        • Chrome (web)     • chrome           • web-javascript • Google Chrome 123.0.6312.124
    
    [✓] Network resources
        • All expected network resources are available.
    
    • No issues found!
    [!] Flutter (Channel master, 3.22.0-16.0.pre.56, on macOS 14.1 23B74 darwin-x64, locale en-VN)
        • Flutter version 3.22.0-16.0.pre.56 on channel master at /Users/huynq/Documents/GitHub/flutter_master
        ! Warning: `flutter` on your path resolves to /Users/huynq/Documents/GitHub/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/huynq/Documents/GitHub/flutter_master. Consider adding /Users/huynq/Documents/GitHub/flutter_master/bin to the front of your path.
        ! Warning: `dart` on your path resolves to /Users/huynq/Documents/GitHub/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/huynq/Documents/GitHub/flutter_master. Consider adding /Users/huynq/Documents/GitHub/flutter_master/bin to the front of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 1bfdc4f06e (2 hours ago), 2024-04-24 22:27:20 -0400
        • Engine revision 2f48456a42
        • Dart version 3.5.0 (build 3.5.0-97.0.dev)
        • DevTools version 2.35.0-dev.8
        • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
        • Android SDK at /Users/huynq/Library/Android/sdk
        • Platform android-34, build-tools 34.0.0
        • ANDROID_HOME = /Users/huynq/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 15.3)
        • Xcode at /Applications/Xcode15.3.app/Contents/Developer
        • Build 15E204a
        • CocoaPods version 1.15.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2023.2)
        • Android Studio at /Applications/Android Studio.app/Contents
        • 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
        • android-studio-dir = /Applications/Android Studio.app/
        • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
    
    [✓] VS Code (version 1.88.1)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.86.0
    
    [✓] Connected device (3 available)
        • iPhone (mobile) • d9a94afe2b649fef56ba0bfeb052f0f2a7dae95e • ios            • iOS 15.8 19H370
        • macOS (desktop) • macos                                    • darwin-x64     • macOS 14.1 23B74 darwin-x64
        • Chrome (web)    • chrome                                   • web-javascript • Google Chrome 124.0.6367.79
    
    [✓] Network resources
        • All expected network resources are available.
    
    ! Doctor found issues in 1 category.

    cc: @TahaTesser for thoughts (The related PR #127662)

  3. changed the title [-]DatePickerThemeData's `rangePickerHeaderBackgroundColor` not being applied to DateRangePickerDialog[/-] [+]DatePickerThemeData's `rangePickerHeaderBackgroundColor` not being applied to DateRangePickerDialog on M2[/+] on Apr 25, 2024
  4. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    p: material_uimaterial_ui package in flutter/packages
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    team-designOwned by Design Languages team
    and removed
    in triagePresently being triaged by the triage team
    on Apr 25, 2024
  5. LuisMiguelSS commented on Apr 25, 2024

    @LuisMiguelSS
    Author

    Thanks for the quick reply!
    I guess that perhaps this is a form of "encouragement" for switching to Material 3, but, in my opinion, we could make this working back for M2.

    In the docs for useMaterial3, it states:

    If false, then components will continue to use the colors, typography and other features of Material 2
    Which, at least for this concrete property, is not the case.

    This is perhaps also happening to more properties, so I'm unsure about the places where this would need to be checked (if the idea is to allow this back ""everywhere"").

    Sidenote: I tested with useMaterial3: true, and can confirm that the background color of the header applies in this case, as you mentioned in the related code.

  6. TahaTesser commented on Apr 25, 2024

    @TahaTesser
    Contributor

    Thanks for the report. I fixed this for M3 in #127662.
    Agree that it should be supported for M2 as well.

  7. self-assigned this
    on Apr 25, 2024
  8. moved this from To do to In progress in Nevercodeon Apr 25, 2024
  9. moved this from In progress to PR submitted in Nevercodeon Apr 25, 2024
  10. moved this from PR submitted to Done (PR merged) in Nevercodeon Apr 26, 2024
  11. added
    r: fixedIssue is closed as already fixed in a newer version
    on Apr 26, 2024
  12. github-actions commented on May 10, 2024

    @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.

  13. locked as resolved and limited conversation to collaborators on May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

f: date/time pickerDate or time picker widgetsfound in release: 3.19Found to occur in 3.19found in release: 3.22Found to occur in 3.22frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesr: 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