experiment with streambuilder

This commit is contained in:
Salvatore Giordano
2021-06-01 17:24:26 +02:00
parent 06bf2cdfe5
commit c10166dbff
13 changed files with 342 additions and 234 deletions
@@ -83,14 +83,14 @@ class ChannelImage extends StatelessWidget {
Widget build(BuildContext context) {
final streamChat = StreamChat.of(context);
final channel = this.channel ?? StreamChannel.of(context).channel;
return StreamBuilder<Map<String, dynamic>>(
return BetterStreamBuilder<Map<String, dynamic>>(
stream: channel.extraDataStream,
initialData: channel.extraData,
builder: (context, snapshot) {
String? image;
final chatThemeData = StreamChatTheme.of(context);
if (snapshot.data!.containsKey('image') == true) {
image = snapshot.data!['image'];
if (snapshot.containsKey('image') == true) {
image = snapshot['image'];
} else if (channel.state?.members.length == 2) {
final otherMember = channel.state?.members
.firstWhere((member) => member.user?.id != streamChat.user?.id);
@@ -153,9 +153,7 @@ class ChannelImage extends StatelessWidget {
imageUrl: image,
errorWidget: (_, __, ___) => Center(
child: Text(
snapshot.data?.containsKey('name') ?? false
? snapshot.data!['name'][0]
: '',
snapshot.containsKey('name') ? snapshot['name'][0] : '',
style: TextStyle(
color: chatThemeData.colorTheme.white,
fontWeight: FontWeight.bold,