Flutter Container BoxShadow doesn't show
8,720
You need to do these changes:
- remove the
ClipRRect
widget. - add
borderRadius
insideBoxDecoration
. add an
Offset
to yourBoxShadow
.Container( decoration: BoxDecoration( color: Colors.blue, gradient: LinearGradient( begin: FractionalOffset.bottomLeft, end: FractionalOffset.topRight, colors: <Color>[Colors.purple, Colors.orange], ), borderRadius: BorderRadius.circular(11), boxShadow: [ BoxShadow(color: Colors.yellow, offset: Offset(5.0, 5.0)) ]), child: Material( borderRadius: BorderRadius.circular(11), clipBehavior: Clip.hardEdge, child: InkWell( onTap: () { print("tapped"); }, child: Container( width: ButtonTheme.of(context).minWidth, height: ButtonTheme.of(context).height, child: Center( child: Text( "log in", style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold), ), ), ), ), color: Colors.transparent, ), ),
Author by
Mircea
Updated on December 11, 2022Comments
-
Mircea over 1 year
Here it's my code in this moment:
ClipRRect( borderRadius: BorderRadius.circular(11), child: Container( decoration: BoxDecoration( gradient: LinearGradient( begin: FractionalOffset.bottomLeft, end: FractionalOffset.topRight, colors: <Color>[Colors.purple, AppBaseColors.orange], ), boxShadow: [BoxShadow(color: Colors.yellow)] ), child: Material( child: InkWell( onTap: () { print("tapped"); }, child: Container( width: ButtonTheme.of(context).minWidth, height: ButtonTheme.of(context).height, child: Center( child: Text( "log in", style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold), ), ), ), ), color: Colors.transparent, ), ), ),
WHAT HAVE I TRIED:
- Add the boxShadow in the first Container
- Add the boxShadow in the second Container
- Add another Container with boxShadow as a parent of ClipRRect
- Add the boxShadow in Material as shadowColor (ofc is not working because I don't have any kind of shadow)
- Adding also the spreadRadius and blurRadius in all of the cases from above, but nothing changed.
Any idea what I did wrong?