getAvatarWidget static method
构建头像图片。头像地址为空或网络加载失败时展示指定的默认头像。
Implementation
static Widget getAvatarWidget(
String? imagePath, {
String defaultImagePath = 'avatar_default_single.png',
double? width,
double? height,
BoxFit fit = BoxFit.cover,
}) {
final defaultAvatar = getImageWidget(
defaultImagePath,
width: width,
height: height,
fit: fit,
);
if (imagePath == null || imagePath.isEmpty) return defaultAvatar;
return getImageWidget(
imagePath,
width: width,
height: height,
fit: fit,
errorWidget: defaultAvatar,
);
}