Mohammed Hamdan
Mohammed Hamdan

Reputation: 1355

How to use Stack into CircleAvatar

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

Upvotes: 3

Views: 449

Answers (1)

eamirho3ein
eamirho3ein

Reputation: 17900

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

Upvotes: 1

Related Questions