Search code examples
flutter

Flutter z-index in Column


I want to make shadow in the red circle in image.

image

My code:

  @override
  Widget build(BuildContext context) {
    print('Listing Card Unit Build');
    return Card(
      elevation: 5,
      margin: EdgeInsets.all(10),
      child: Column(
        mainAxisSize: MainAxisSize.min,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          _buildUpperSpace(),
          _buildImageSpace(),
          _buildTextSpace(),
          _buildProductSpace(),
          _buildButtonSpace()
        ],
      )
    );
  }

In code, I want to add shadows between _buildUpperSpace() and _buildImageSpace(), and between all at below of _buildImageSpace() and _buildImageSpace().

So, _buildUpperSpace() have to be on _buildImageSpace(), and all at below of _buildImageSpace() have to be on _buildImageSpace().

Thanks.


Solution

  • You can try wrapping _buildImageSpace() in a Card or Material widget. Both have the elevation property. That's what you are looking for.