Home > Software engineering >  How to add an image inside the circle and make the border have color in Flutter?
How to add an image inside the circle and make the border have color in Flutter?

Time:02-20

I am new in Flutter. I want to add an image inside the circle and make the border have color.

image

I would appreciate any help.

CodePudding user response:

you can use CircleAvatar or Container with BoxDecoration

Container(
          width:105.0,
          height: 105.0,
          padding: const EdgeInsets.all(8.0),
          decoration: BoxDecoration(
            shape: BoxShape.circle,
            border: Border.all(width: 1,color: Colors.blue),
            image: DecorationImage(
              fit: BoxFit.fill,
              image: NetworkImage("https://picsum.photos/500/300?random=1")
            )
          )
        )

CodePudding user response:

you can use a circle avatar which will take an asset image or network image and you can change the border by changing the radius.

CircleAvatar(
              radius: 55,
              backgroundColor: Color(0xffFDCF09),
              child: CircleAvatar(
                radius: 50,
                backgroundImage: AssetImage('images/batman.jpg'),
              ),
            )
  • Related