Home > Net >  How to use Stack into CircleAvatar
How to use Stack into CircleAvatar

Time:08-29

I am trying to put Container color as Stack above circle avatar but the problem is that color go out the circle borer

I have the following code,

                IntrinsicWidth(
                child: Stack(
                  alignment: Alignment.bottomCenter,
                  children: [
                    const CircleAvatar(
                      radius: 50,
                    ),
                    Container(
                      color: Colors.yellowAccent,
                      height: 30,
                    )
                  ],
                ),
              ) 

I get the following output

enter image description here

But I need the output looks like following

enter image description here

How Can I prevent my color from expanding to the circle width

thanks

CodePudding user response:

try this:

CircleAvatar(
  backgroundColor: Colors.yellow,
  radius: 100,
  child: Container(
    alignment: Alignment.bottomCenter,
    clipBehavior: Clip.antiAlias,
    decoration: BoxDecoration(shape: BoxShape.circle),
    child: Container(
      height: 40,
      width: double.infinity,
      color: Colors.red,
    ),
  ),
)

enter image description here

  • Related