diff --git a/lib/src/conditional/io_conditional.dart b/lib/src/conditional/io_conditional.dart index c9dd7e60a..e5be8243e 100644 --- a/lib/src/conditional/io_conditional.dart +++ b/lib/src/conditional/io_conditional.dart @@ -17,6 +17,8 @@ class IOConditional extends BaseConditional { ImageProvider getProvider(String uri, {Map? headers}) { if (uri.startsWith('http')) { return NetworkImage(uri, headers: headers); + } else if (uri.startsWith('assets/')) { + return AssetImage(uri); } else { return FileImage(File(uri)); } diff --git a/lib/src/widgets/message/user_avatar.dart b/lib/src/widgets/message/user_avatar.dart index 6393e178c..cf9a11b54 100644 --- a/lib/src/widgets/message/user_avatar.dart +++ b/lib/src/widgets/message/user_avatar.dart @@ -4,6 +4,7 @@ import 'package:flutter_chat_types/flutter_chat_types.dart' as types; import '../../models/bubble_rtl_alignment.dart'; import '../../util.dart'; import '../state/inherited_chat_theme.dart'; +import '../../conditional/conditional.dart'; /// Renders user's avatar or initials next to a message. class UserAvatar extends StatelessWidget { @@ -50,7 +51,10 @@ class UserAvatar extends StatelessWidget { .userAvatarImageBackgroundColor : color, backgroundImage: hasImage - ? NetworkImage(author.imageUrl!, headers: imageHeaders) + ? Conditional().getProvider( + author.imageUrl!, + headers: imageHeaders, + ) : null, radius: 16, child: !hasImage