Skip to content

[Material] Hardcoded Colors.black54 used for scrims/barriers instead of ColorScheme.scrim #190824

Closed
flutter/packages
#12746

Description

@mmohankrishna-lab

Steps to reproduce

Refernce : b/293423836

  1. Run the code sample provided below.
  2. Click on the "Open Drawer" button (or swipe from the left).
  3. Observe the color of the background scrim that dims the rest of the screen.
  4. Close it and click on "Open Modal Bottom Sheet" or "Open Dialog".
  5. Observe the barrier color for those modals as well.

Expected results

When useMaterial3 is enabled, the modals should respect the ColorScheme.scrim token. The background scrim should appear as Red (with the standard framework opacity applied, e.g., 54%), matching the customization made in the theme.

Actual results

The background scrim/dimming effect remains a dark grey/translucent black (Colors.black54). The framework completely ignores the custom Colors.red defined in ColorScheme.scrim.

Code sample

Code sample
import 'package:flutter/material.dart';
 
 void main() {
   runApp(const MyApp());
 }
 
 class MyApp extends StatelessWidget {
   const MyApp({super.key});
 
   @override
   Widget build(BuildContext context) {
     return MaterialApp(
       title: 'Scrim Color Demo',
       theme: ThemeData(
         useMaterial3: true,
         colorScheme: ColorScheme.fromSeed(
           seedColor: Colors.deepPurple,
           // 🔴 We set a custom, highly visible scrim color (e.g., Red)
           scrim: Colors.red, 
         ),
       ),
       home: const MyHomePage(),
     );
   }
 }
 
 class MyHomePage extends StatelessWidget {
   const MyHomePage({super.key});
 
   @override
   Widget build(BuildContext context) {
     return Scaffold(
       appBar: AppBar(title: const Text('Scrim Bug Demo')),
       // Drawer will use the default scrim
       drawer: const Drawer(
         child: Center(child: Text('Drawer Content')),
       ),
       body: Center(
         child: Column(
           mainAxisAlignment: MainAxisAlignment.center,
           children: <Widget>[
             // Builder is used to get the correct context for Scaffold.of
             Builder(
               builder: (context) {
                 return ElevatedButton(
                   onPressed: () => Scaffold.of(context).openDrawer(),
                   child: const Text('Open Drawer'),
                 );
               },
             ),
             const SizedBox(height: 20),
             ElevatedButton(
               onPressed: () {
                 showModalBottomSheet(
                   context: context,
                   builder: (context) => const SizedBox(
                     height: 200,
                     child: Center(child: Text('Bottom Sheet Content')),
                   ),
                 );
               },
               child: const Text('Open Modal Bottom Sheet'),
             ),
             const SizedBox(height: 20),
             ElevatedButton(
               onPressed: () {
                 showDialog(
                   context: context,
                   builder: (context) => AlertDialog(
                     title: const Text('Dialog'),
                     content: const Text('Dialog Content'),
                     actions: [
                       TextButton(
                         onPressed: () => Navigator.pop(context),
                         child: const Text('Close'),
                       ),
                     ],
                   ),
                 );
               },
               child: const Text('Open Dialog'),
             ),
           ],
         ),
       ),
     );
   }
 }

Screenshots or Video

Screenshots Image Image

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Flutter Doctor
[✓] Flutter (Channel master, 3.47.0-0.4.pre, on Debian GNU/Linux rodete 6.18.14-1rodete4-amd64,
    locale en_US.UTF-8) [5.0s]
    • Flutter version 3.47.0-0.4.pre on channel master at
      /usr/local/google/home/mmohankrishna/developement/flutter
    • Upstream repository [email protected]:flutter/flutter.git
    • Framework revision 5c6367c2ab (5 weeks ago), 2026-07-07 06:58:20 +0200
    • Engine revision 6a5b0bdd7a
    • Dart version 3.13.0 (build 3.13.0-275.0.dev)
    • DevTools version 2.59.0
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop,
      enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets,
      enable-record-use, enable-swift-package-manager, omit-legacy-version-file,
      enable-lldb-debugging, enable-uiscene-migration, enable-riscv64

[✓] Android toolchain - develop for Android devices (Android SDK version 36.1.0) [2.2s]
    • Android SDK at /usr/local/google/home/mmohankrishna/Android/Sdk
    • Emulator version 36.6.11.0 (build_id 15507667) (CL:N/A)
    • Platform android-36.1, build-tools 36.1.0
    ! Multiple adb binaries found. This can cause conflicts and device detection issues:
        - /usr/local/google/home/mmohankrishna/Android/Sdk/platform-tools/adb
        - /usr/bin/adb
    • Java binary at:
      /usr/local/google/home/mmohankrishna/Downloads/android-studio-quail1-patch2-linux/android-s
      tudio/jbr/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.10+-14961533-b1163.108)
    • All Android licenses accepted.

[✓] Chrome - develop for the web [14ms]
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop [524ms]
    • Debian clang version 21.1.8 (3)
    • cmake version 4.2.3
    • ninja version 1.13.2
    • pkg-config version 2.5.1
    • OpenGL core renderer: llvmpipe (LLVM 21.1.8, 256 bits)
    • OpenGL core version: 4.5 (Core Profile) Mesa 26.0.2-1
    • OpenGL core shading language version: 4.50
    • OpenGL ES renderer: llvmpipe (LLVM 21.1.8, 256 bits)
    • OpenGL ES version: OpenGL ES 3.2 Mesa 26.0.2-1
    • OpenGL ES shading language version: OpenGL ES GLSL ES 3.20
    • GL_EXT_framebuffer_blit: yes
    • GL_EXT_texture_format_BGRA8888: yes

[✓] Connected device (2 available) [158ms]
    • Linux (desktop) • linux  • linux-x64      • Debian GNU/Linux rodete 6.18.14-1rodete4-amd64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 151.0.7922.108

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

• No issues found!

Activity

  1. added
    in triage
    on Aug 10, 2026
  2. saurabh-mirajkar commented on Aug 10, 2026

    @saurabh-mirajkar
    Contributor

    @mmohankrishna-lab Thanks for the report. Could you please provide the output of flutter doctor -v where this reproduces? Also, please include screenshots / video sample of the observed scrim color if possible.

  3. added
    waiting for response
    needs repro info
    and removed
    in triage
    on Aug 10, 2026
  4. mmohankrishna-lab commented on Aug 11, 2026

    @mmohankrishna-lab
    Author

    @saurabh-mirajkar I've provided the output of flutter doctor -v and aslo attached the screenshots

  5. removed
    waiting for response
    on Aug 11, 2026
  6. added
    in triage
    on Aug 11, 2026
  7. saurabh-mirajkar commented on Aug 11, 2026

    @saurabh-mirajkar
    Contributor

    @mmohankrishna-lab Thanks for providing additional details. I was able to reproduce on latest stable using the provided code sample, so labelling and passing it on to the design team for further investigation.

  8. added
    framework
    p: material_ui
    has reproducible steps
    team-design
    and removed
    in triage
    needs repro info
    on Aug 11, 2026
  9. byshy commented on Aug 11, 2026

    @byshy

    I’d like to work on this.

    Proposed fix: when barrier/scrim color isn’t set via the widget or component theme, fall back to Theme.of(context).colorScheme.scrim.withValues(alpha: 0.54) instead of Colors.black54 for dialogs, modal bottom sheets, and drawers (keeps the default look; honors a custom ColorScheme.scrim).

    Does that match what the design team wants?

  10. developerashkan commented on Aug 12, 2026

    @developerashkan

    Hi! I'd like to take a look at this one — no one is assigned yet. I can reproduce it with a ColorScheme.fromSeed(seedColor: ..., scrim: Colors.red) theme: showModalBottomSheet, dialogs and the drawer scrim all still render Colors.black54 instead of the configured ColorScheme.scrim when useMaterial3 is enabled.

    Plan: update the Material scrim/barrier color usage (drawer scrim, showModalBottomSheet, dialogs) to read from Theme.of(context).colorScheme.scrim, add a test, and run the framework's material widget tests. If you'd prefer a different approach or this is already in progress, let me know and I'll stand down.

    If that sounds good, please assign me and I'll get started.

  11. Piinks commented on Aug 12, 2026

    @Piinks
    Contributor

    Hi @developerashkan please do not push a PR to fix an issue when there is one already open. There are many contributors to the Flutter project and many of them are not able to assign themselves to issues.

  12. developerashkan commented on Aug 13, 2026

    @developerashkan

    @Piinks Got it, thanks for clarifying. It would be helpful to close stale PRs first though, I still have a previous PR open for a different issue.

  13. added
    package
    and removed
    framework
    on Aug 17, 2026
  14. elliette commented on Sep 1, 2026

    @elliette
    Member

    cc @QuncCccccc for triage

  15. added
    P2
    triaged-design
    on Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2has reproducible stepsp: material_uipackageteam-designtriaged-design

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions