getAvatarImage function
Implementation
getAvatarImage(String? url, {double? radius, String? fileId}) {
if (url != null) {
var imageOPS = OptimizedCacheImage(
imageBuilder: (context, imageProvider) => Container(
child: CircleAvatar(
radius: radius,
backgroundColor: Colors.transparent,
backgroundImage: (imageProvider)),
),
imageUrl: url,
fit: BoxFit.fill,
placeholder: (context, url) => CircleAvatar(
radius: radius,
backgroundColor: Colors.transparent,
backgroundImage: AssetImage("assets/images/user_placeholder.png")),
errorWidget: (context, url, error) => Icon(Icons.error),
);
return imageOPS;
} else if (fileId != null) {
var imageOPS = OptimizedCacheImage(
imageBuilder: (context, imageProvider) => CircleAvatar(
backgroundColor: Colors.transparent,
backgroundImage: (imageProvider)),
imageUrl:
"https://api.${env!.region}.amity.co/api/v3/files/${fileId}/download?size=full",
fit: BoxFit.fill,
placeholder: (context, url) => CircleAvatar(
radius: radius,
backgroundColor: Colors.transparent,
backgroundImage: AssetImage("assets/images/user_placeholder.png")),
errorWidget: (context, url, error) => Icon(Icons.error),
);
return imageOPS;
} else {
return CircleAvatar(
radius: radius,
backgroundColor: Colors.transparent,
backgroundImage: AssetImage("assets/images/user_placeholder.png"));
}
}