Skip to content

Update elevation overlay to apply in both light and dark theme #91607

Description

@rami-a

As part of Material 3, the elevation overlay is changing in a few ways (link to https://material.io spec to come soon)

  • it will now apply in both light and dark theme
  • it will use a different color (primary) to blend with the surface and the calculation is slightly tweaked

Activity

  1. added
    p: material_uimaterial_ui package in flutter/packages
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Oct 11, 2021
  2. MCarlomagno commented on Oct 20, 2021

    @MCarlomagno

    Hi Rami, I would like to contribute to the Material 3 migration, but seems that there is no public official guideline to start working on it.
    I see that some Google applications are starting to use it, so I guess there is a guideline but is still unpublished, is there a way to have access to it?

    Thanks!

  3. rami-a commented on Oct 20, 2021

    @rami-a
    ContributorAuthor

    Hey @MCarlomagno thanks for your interest in helping with Material 3! At the moment there is no public guidance but it will be published soon (in the next couple of weeks). At that time, we will have more of a concrete plan for how these updates will be brought to Flutter and should be able to accept your help then. Stay tuned!

  4. MCarlomagno commented on Oct 20, 2021

    @MCarlomagno

    Sounds good, thanks a lot for the info :)

  5. bernaferrari commented on Oct 27, 2021

    @bernaferrari
    Contributor
  6. rydmike commented on Nov 2, 2021

    @rydmike
    Contributor

    @rami-a on a related note.

    I ran into some limitations when using more nuanced dark themes and the way the current elevation color is applied in the SDK by the applyOverlay function.

    I proposed a fix for it here #90353 (comment) that would help. However, since I suspected that Material 3 would bring in some new features to this, I decided to wait and see what it brings. Also, I never got around to check if the fix would break any tests, it might not actually.

    Looking at Material3 spec it looks like this will be interesting and certainly a new much more powerful and more nuanced way of handling it.

    However, I don't think it will solve the issue I was having with the applyOverlay function in Material2. So I think it would still be nice if that worked more as expected and was applied more generally to Material surfaces by the applyOverlay function, by recognizing color property values that may be used by Material in various widget, both via colorScheme properties and the various legacy ThemeData background colors, while they still exist.

    Current issue with applyOverlay on M2 Material using widgets

    The current issue with applyOverlay is that overlay color is only applied to Material that happens to use a color value that is equal to the colorScheme.surface color value. Problems occur if you create dark themes where you have slightly nuanced differences on various background color properties, primarily then on colorScheme.background.

    You might do so if you use eg slightly different colorScheme.primary color alpha blend strength for your colorScheme.background color, compared to colorScheme.surface, then you get no elevation overlay applied in dark mode to Widgets that use colorScheme.background as their default background color.

    Actually most widgets still use the ThemeData colors cardColor or canvasColor/backgroundColor, depending on what type of Material the widget is using or widget. Those color properties in return are set to colorScheme.surface and colorScheme.background respectively, by ThemeData() factory or ThemeData.from() factory.

    The ThemeData colors cardColor, canvasColor, backgroundColor and dialogBackgroundColor are known deprecation targets, but it would still be nice and proper to included them while they still exist, so the experience is more in line what can be expected from elevation overlay color. Still, even just adding colorScheme.background to the applyOverlay function, as a recognized Material surface color that should get elevation overlay in dark mode, when so configured, would go a long way.

  7. bernaferrari commented on Nov 2, 2021

    @bernaferrari
    Contributor

    @rydmike you should collaborate on issue 91605 (I'm not even going to link it here).

  8. cedvdb commented on Feb 18, 2022

    @cedvdb
    Contributor

    Will this be opt in or every one will have that when it is available ? Just so I get a mental reminder there is a need to opt in.

  9. rami-a commented on Feb 18, 2022

    @rami-a
    ContributorAuthor

    This change would be tied to the currently available useMaterial3 flag on ThemeData once it is implemented.

    cc @darrenaustin

  10. changed the title [-][Material 3] Update elevation overlay to apply in both light and dark theme[/-] [+]Update elevation overlay to apply in both light and dark theme[/+] on Mar 30, 2022
  11. github-actions commented on Apr 13, 2022

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

  12. locked as resolved and limited conversation to collaborators on Apr 13, 2022
  13. moved this to Todo in Material 3on May 23, 2022
  14. moved this from Todo to Done in Material 3on May 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

frameworkflutter/packages/flutter repository. See also f: labels.p: material_uimaterial_ui package in flutter/packages

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions