Home > Net >  how to change shape of CircleAvatar widget?
how to change shape of CircleAvatar widget?

Time:02-16

cell item

I want to change the shape of first circle avatar. Is it possible using .of(context).copyWith?. Because CircleAvatar has used AnimatedContainer for shape.

CodePudding user response:

No, you can't change the shape of a CircleAvatar to be anything other than a circle. It is not possible to modify a Widget after it was instantiated.

Instead, create your own Widget using composition. Let you guide by the CircleAvatar implementation.

Container(
    duration: Duration(milliseconds: 300),
    decoration: BoxDecoration(
      image: DecorationImage(
        image: image,
        fit: BoxFit.cover,
      ),

    // your own shape
    shape: BoxShape.rectangle,
    ),
),

CodePudding user response:

Please see the code below:

Container(
  width: 45.0,
  height: 45.0,
  decoration: const BoxDecoration(
    color: Color.fromARGB(255, 25, 20, 45),
    borderRadius: BorderRadius.all(
       Radius.circular(18),
    ),
),
child: const Center(
  child: FaIcon(
    FontAwesomeIcons.bitcoin,
    color: Colors.amber,
  ),
),
),
  • Related