I am using a CircleAvatar with a backgroundImage
property to load an image took from a camera but the image shown does not fill the entire circle avatar. It looks like a rectangular image in a circle.
How do I make the image expand to cover the circle avatar? Thanks.
To change the avatar size, you can use radius property. There are two other properties related to size: minRadius and maxRadius . The are used to set the minimum and maximum radius respectively. If you alredy use radius , you are not allowed to use minRadius and/or maxRadius .
This property applies a background image to the CircleAvatar widget. child: The child property takes the widget to be placed below the CircleAvatar widget inside the widget tree or the widget to be displayed inside the circle. foregroundColor: This property holds the Color class (final) as the parameter value.
You can always create an image and manually clip it:
ClipOval(
child: Image.network(
"url.jpg",
fit: BoxFit.cover,
width: 90.0,
height: 90.0,
)
),
If you are using a local image from asset then you can use CircleAvatar as,
CircleAvatar(
backgroundImage: ExactAssetImage('assets/images/cook.jpeg'),
// Optional as per your use case
// minRadius: 30,
// maxRadius: 70,
),
If you are using a network image then you can use CircleAvatar as,
CircleAvatar(
radius: 30.0,
backgroundImage: NetworkImage(imageURL),
backgroundColor: Colors.transparent,
));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With