Skip to content

Adjacent Material Widgets in a Column/Row do not cast a shadow on each other #12206

Open

Description

@zzzev

Internal: b/292548582

Steps to Reproduce

When you create a widget that has a build method like this:

Widget build(BuildContext context) => return new Scaffold(
      appBar: new AppBar(
        title: new Text('Test'),
      ),
      body: new Column(
        children: <Widget>[
          new Material(
            color: Colors.blue.shade500,
            child: new Container(height: 100.0),
            elevation: 20.0,
          ),
          new Material(
            color: Colors.white,
            child: new Container(height: 100.0),
            elevation: 10.0,
          ),
          new Material(
            color: Colors.orange.shade500,
            child: new Container(height: 100.0),
            elevation: 20.0,
          ),
        ],
      ),
    );

You get this result:
screenshot_1506024976

As you can see, only the shadow from the bottom-most, orange Material is rendered. I would expect there to be a shadow rendered over the middle, white Material from both the above and below, as both of those have higher elevation.

For bonus points, I would also expect the shadow over the white Material to be about half as large as the one cast over the scaffold background by the orange Material (because the former is going from elevation 20 to 10, while the latter is going from elevation 20 to 0).

Activity

  1. zzzev commented on Sep 21, 2017

    @zzzev
    ContributorAuthor

    Additionally -- though I'm less sure of this part -- the top Material should probably also be casting a shadow on the AppBar, which has an elevation of 6.0 vs. the Material's elevation of 20.0, but instead the Material has a shadow cast onto it from the AppBar.

  2. Hixie commented on Sep 21, 2017

    @Hixie
    Contributor

    We don't do "real" shadows on Android and iOS, so I wouldn't expect the shadows to paint according to the elevations (e.g. the blue material should paint under the white material and the appbar).

    It's weird that the white and orange boxes don't paint shadows on their previous siblings though...

  3. Hixie commented on Sep 21, 2017

    @Hixie
    Contributor

    What happens if you flip the order of the boxes and use verticalDirection: VerticalDirection.up on the column?

  4. zzzev commented on Sep 21, 2017

    @zzzev
    ContributorAuthor

    With your suggested change:
    screenshot_1506026590

    This makes more sense, but even with everything you mention I'm surprised the blue Material isn't casting a shadow upwards onto the scaffold like the orange one does in the first screenshot.

    This also makes me even more confused about why the white one has no shadow in the first screenshot, very confusing. I think there must be some bug here, though I'm not sure how to dig in further exactly.

    Aside from this behavior, a question: given this, if we do want to control the z-indexing more explicitly (i.e. to enable a layout like the one implied by the first example), is using a Stack or other more complex layout widget the way to go? It would be nice if we could get the layout behavior or row/column but decoupled from the ordering of rendering, i.e. allowing us to specify render ordering (in terms of timing, not layout), sort of like the inverse of how flex-box in css allows you to specify the order property.

  5. Hixie commented on Sep 21, 2017

    @Hixie
    Contributor

    There's definitely a bug here, though I can't imagine what it is. It's almost like we're clipping more than we should...

    To control the paint order, you can use verticalDirection, that's basically what I was testing above. We don't have a trivial way with Column to control the order in more precision than that. You can of course make your own layout widgets and then you can have them paint in whatever order you want.

  6. JeffersonBledsoe commented on Sep 8, 2018

    @JeffersonBledsoe

    Just came across this myself and a quick workaround is to reverse the order of children in the column and set the verticalDirection to VerticalDirection.up. This causes the drop shadow to be drawn correctly.

    screen shot 1

  7. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    engineflutter/engine related. See also e: labels.
    on Sep 8, 2018
  8. added this to the milestone on Sep 8, 2018
  9. added a commit that references this issue on Sep 11, 2019
  10. added a commit that references this issue on Sep 12, 2019
  11. added a commit that references this issue on Sep 12, 2019
  12. 17 remaining items

  13. yahya-uddin commented on Jun 14, 2022

    @yahya-uddin

    Any update on this issue?

  14. added
    customer: crowdAffects or could affect many people, though not necessarily a specific customer.
    on Dec 27, 2022
  15. darshankawar commented on Dec 27, 2022

    @darshankawar
    Member

    Verified on latest versions and observed that the issue persists.

    Screenshot 2022-12-27 at 5 12 47 PM

    stable, master flutter doctor -v
    [✓] Flutter (Channel stable, 3.3.10, on macOS 12.2.1 21D62 darwin-x64, locale
        en-GB)
        • Flutter version 3.3.10 on channel stable at
          /Users/dhs/documents/fluttersdk/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 135454af32 (15 hours ago), 2022-12-15 07:36:55 -0800
        • Engine revision 3316dd8728
        • Dart version 2.18.6
        • DevTools version 2.15.0
    
    [!] Xcode - develop for iOS and macOS (Xcode 12.3)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        ! Flutter recommends a minimum Xcode version of 13.
          Download the latest version or update via the Mac App Store.
        • CocoaPods version 1.11.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] VS Code (version 1.62.0)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.21.0
    
    [✓] Connected device (5 available)
        • SM G975F (mobile)       • RZ8M802WY0X • android-arm64   • Android 11 (API 30)
        • Darshan's iphone (mobile)  • 21150b119064aecc249dfcfe05e259197461ce23 •
          ios            • iOS 14.4.1 18D61
        • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729     •
          ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
        • macOS (desktop)            • macos                                    •
          darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
        • Chrome (web)               • chrome                                   •
          web-javascript • Google Chrome 98.0.4758.80
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    ! Doctor found issues in 1 category.
    
    [!] Flutter (Channel master, 3.7.0-13.0.pre.51, on macOS 12.2.1 21D62
        darwin-x64, locale en-GB)
        • Flutter version 3.7.0-13.0.pre.51 on channel master at
          /Users/dhs/documents/fluttersdk/flutter
        ! Warning: `flutter` on your path resolves to
          /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside
          your current Flutter SDK checkout at
          /Users/dhs/documents/fluttersdk/flutter. Consider adding
          /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path.
        ! Warning: `dart` on your path resolves to
          /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your
          current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter.
          Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front
          of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 6441a7dc62 (3 hours ago), 2022-12-22 20:38:18 -0500
        • Engine revision 12badb5459
        • Dart version 3.0.0 (build 3.0.0-60.0.dev)
        • DevTools version 2.20.0
        • If those were intentional, you can disregard the above warnings; however
          it is recommended to use "git" directly to perform update checks and
          upgrades.
    
    [!] Xcode - develop for iOS and macOS (Xcode 12.3)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        ! Flutter recommends a minimum Xcode version of 13.
          Download the latest version or update via the Mac App Store.
        • CocoaPods version 1.11.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] VS Code (version 1.62.0)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.21.0
    
    [✓] Connected device (5 available)
        • SM G975F (mobile)       • RZ8M802WY0X • android-arm64   • Android 11 (API 30)
        • Darshan's iphone (mobile)  • 21150b119064aecc249dfcfe05e259197461ce23 •
          ios            • iOS 14.4.1 18D61
        • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729     •
          ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
        • macOS (desktop)            • macos                                    •
          darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
        • Chrome (web)               • chrome                                   •
          web-javascript • Google Chrome 98.0.4758.80
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    ! Doctor found issues in 1 category.
    
    
    
    
  16. added
    packageflutter/packages repository. See also p: labels.
    and removed
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listcustomer: crowdAffects or could affect many people, though not necessarily a specific customer.customer: mulligan (g3)engineflutter/engine related. See also e: labels.found in release: 3.3Found to occur in 3.3found in release: 3.7Found to occur in 3.7has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagespackageflutter/packages repository. See also p: labels.team-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions