Skip to content

[material_ui] Use ColorScheme.scrim for modal barrier/scrim defaults - #12746

Open
byshy wants to merge 3 commits into
flutter:mainfrom
byshy:fix-color-scheme-scrim-barriers
Open

[material_ui] Use ColorScheme.scrim for modal barrier/scrim defaults#12746
byshy wants to merge 3 commits into
flutter:mainfrom
byshy:fix-color-scheme-scrim-barriers

Conversation

@byshy

@byshy byshy commented Sep 4, 2026

Copy link
Copy Markdown

When modal barrier or drawer scrim colors are not set via an explicit parameter or component theme, fall back to ColorScheme.scrim with an opacity matching Colors.black54 instead of hardcoding Colors.black54.

This allows apps that customize ColorScheme.scrim to theme dialog, modal bottom sheet, and drawer scrims consistently, while preserving the default appearance for the standard black scrim token.

Fallback order remains:

  1. Explicit parameter (barrierColor / drawerScrimColor)
  2. Component theme (DialogTheme, BottomSheetTheme, DrawerTheme)
  3. Theme.of(context).colorScheme.scrim.withValues(alpha: Colors.black54.a)

Ports flutter/flutter#190911
Work towards flutter/flutter#188444

Fixes flutter/flutter#190824

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2

Enhance the handling of modal barrier colors in bottom sheets, dialogs, and drawers to utilize ColorScheme.scrim with an opacity matching Colors.black54 when no specific color is provided. This change ensures a consistent appearance across components and allows for better theme integration. Additionally, tests have been added to verify the new behavior and precedence rules for barrier colors.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the default fallback colors for dialog, modal bottom sheet, and drawer barriers/scrims to use ColorScheme.scrim with an opacity matching Colors.black54 when no explicit color or theme-specific color is provided. It also updates the corresponding documentation, adds a pending changelog entry, and introduces comprehensive widget tests to verify the new fallback behavior and precedence rules. There are no review comments, so I have no feedback to provide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p: material_ui triage-design Should be looked at in design triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant