avatarBuilderWithURL method

Widget avatarBuilderWithURL(
  1. BuildContext context,
  2. Size size,
  3. ZegoUIKitUser? user,
  4. Map<String, dynamic> extraInfo,
)

Implementation

Widget avatarBuilderWithURL(
  BuildContext context,
  Size size,
  ZegoUIKitUser? user,
  Map<String, dynamic> extraInfo,
) {
  return ValueListenableBuilder(
    valueListenable: ZegoUIKitUserPropertiesNotifier(
      user ?? ZegoUIKitUser.empty(),
    ),
    builder: (context, _, __) {
      final avatarURL = user?.inRoomAttributes.value.avatarURL ?? '';
      return avatarBuilder?.call(
            context,
            size,
            user,
            extraInfo,
          ) ??
          (avatarURL.isNotEmpty
              ? CachedNetworkImage(
                  imageUrl: avatarURL,
                  imageBuilder: (context, imageProvider) => Container(
                    decoration: BoxDecoration(
                      shape: BoxShape.circle,
                      image: DecorationImage(
                        image: imageProvider,
                        fit: BoxFit.cover,
                      ),
                    ),
                  ),
                  progressIndicatorBuilder:
                      (context, url, downloadProgress) =>
                          CircularProgressIndicator(
                              value: downloadProgress.progress),
                  errorWidget: (context, url, error) {
                    ZegoLoggerService.logError(
                      '$user avatar url($url) error:$error',
                      tag: 'uikit',
                      subTag: 'avatar',
                    );
                    return circleName(context, avatarSize, user);
                  },
                )
              : circleName(context, avatarSize, user));
    },
  );
}