getAvatarWidget static method

Widget getAvatarWidget(
  1. String? imagePath, {
  2. String defaultImagePath = 'avatar_default_single.png',
  3. double? width,
  4. double? height,
  5. BoxFit fit = BoxFit.cover,
})

构建头像图片。头像地址为空或网络加载失败时展示指定的默认头像。

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,
  );
}