flutter / flutter/flutter

Add an `elevationToShadow` option to override default M3 shadows in `ThemeData`

Open
#159,677 4 comments 1 reaction 0 assignees View on GitHub
c: proposal p: material_ui P3 package team-design triaged-design
Dominant language
Dart
Stars
179k
Forks
31.1k
PR merge metrics
PR metrics pending

Description

### Use case

Design of an app may be built upon M3 widgets, but with different shadows
i.e.
| elevation | y | blur |
|-----------|----|------|
| 1 | 4 | 8 |
| 2 | 6 | 8 |
| 3 | 10 | 10 |

Would look cool:
Screenshot 2024-12-02 at 21 07 23

But at the moment to override all shadows in my app - I need not only to replace all `Card` with `Container`, but also wriggle around `ContextMenu`, `BottomSheet` etc

Now they're just hardcoded here _(since k in constants was good practice)_
https://github.com/flutter/flutter/blob/a0ba2decab156c88708c4261d40660ab8f60da5f/packages/flutter/lib/src/material/shadows.dart#L40

And being used like this
https://github.com/flutter/flutter/blob/a0ba2decab156c88708c4261d40660ab8f60da5f/packages/flutter/lib/src/material/dropdown.dart#L57-L64

### Proposal

My proposal is to add `shadowToElevation` parameter in `ThemeData`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.