I am trying to display a users profile picture inside a circle avatar widget but only a small portion of it is displayed.
CircleAvatar(
radius: 70,
backgroundImage: AssetImage("Images/headshot_1.jpg"),
)
Image I am trying to display
Screenshot on emulator:
Update: I got it to work by wrapping the circle avatar in a row widget.
Wrap CircleAvatar widget with Center widget Example:
Center(child:CircleAvatar())
I'd try using foregroundImage
. As the official documentation states, this property works well in your use case: a profile picture.
Here's an example with the image you displayed in your question:
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
child: CircleAvatar(
foregroundImage: AssetImage(
'myimage.png',
),
),
),
),
);
}
}
EDIT. Added the obtained UI.
Here's what I obtain:
If your problem persists, the problem lies somewhere else in your context / widget tree.
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