Add shadow to CircleAvatar

4,431 views
Skip to first unread message

Prashant Singh

unread,
Jul 30, 2018, 12:22:33 AM7/30/18
to Flutter Dev
Trying to add shadow to CircleAvatar.

please find attached screenshot and also the code.
Tried wrapping it to a Container to try BoxShadow via BoxDecoration. 
Have given Radius to add Circularity to the Container but not able to get the Width right.
Please help.

final logo = Hero(
    tag
: 'hero',
    child
: Container(
    decoration
: new BoxDecoration(
       
borderRadius: BorderRadius.circular(48.0),
       boxShadow
: [new BoxShadow(
          color
: Colors.white70,
          blurRadius
: 20.0
       
)]
   
),
    child
: CircleAvatar(
       backgroundColor
: Colors.white,
        radius
: 48.0,
        child
: Image.asset(
         
'assets/images/logo.png',
           width
: 55.0,
           height
: 55.0,
           fit
: BoxFit.cover,
       
),
   
),
 
),
);

Screenshot_20180730-094617.png

Greg Spencer

unread,
Jul 30, 2018, 1:36:47 AM7/30/18
to Prashant Singh, Flutter Dev
The Container is filling the width of the screen, so the box decoration is doing the expected thing.  Try giving the container the width and height that you want (55 or 48, or whatever) with the width and height attributes.  There are also other ways you could lay this out.  For instance, you probably don't even need the CircleAvatar once the Container is the right size: the border will form the circle you're looking for, and the child of the Container could be your image asset instead.

-Greg.

--
You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Prashant Singh

unread,
Jul 30, 2018, 5:43:07 AM7/30/18
to gspe...@google.com, flutt...@googlegroups.com
Thanks!! Done without CircleAvatar using shape property of BoxDecoration inside Container.
Reply all
Reply to author
Forward
0 new messages