Reputation: 441
CircleAvatar(
radius: 30.0,
backgroundColor: Colors.white,
child: (_imageFile != null)
? Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
image: DecorationImage(
image: FileImage(_imageFile),
fit: BoxFit.fill),
),
)
: Image.network(snapshot.data//If url is empty it'll return an error
.photoUrl),//Replace with Image From DB
),
The container holds an image if the user changing the picture, else Image from the database will appear but if the photoUrl
is empty it'll return an error saying 'url != null : is not true'
if url==null how can I replace the CircleAvatar
with an Icon
Upvotes: 1
Views: 1676
Reputation: 1914
Try this:
CircleAvatar(
backgroundColor: Colors.grey[300],//if there's no background image provided
backgroundImage: (netimage == null)?null:NetworkImage(netimage),//add URL to netimage
radius: 25.0,//radius of the circle avatar
),
This may help you
Upvotes: 1