update dependencies

This commit is contained in:
Salvatore Giordano
2020-04-20 09:43:54 +02:00
parent 7c2d607a3a
commit b20ba2e306
7 changed files with 57 additions and 37 deletions
+20 -9
View File
@@ -38,7 +38,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
/// The widget uses a [StreamBuilder] to render the channel information image as soon as it updates.
///
/// By default the widget radius size is 40x40 pixels.
/// Set the property [size] to set a custom dimension.
/// Set the property [constraints] to set a custom dimension.
///
/// The widget renders the ui based on the first ancestor of type [StreamChatTheme].
/// Modify it to change the widget appearance.
@@ -47,38 +47,49 @@ class ChannelImage extends StatelessWidget {
const ChannelImage({
Key key,
this.channel,
this.size = 40,
this.constraints,
}) : super(key: key);
/// The channel to show the image of
final Channel channel;
/// The diameter of the image
final double size;
final BoxConstraints constraints;
@override
Widget build(BuildContext context) {
final client = StreamChat.of(context);
final channel = this.channel ?? StreamChannel.of(context).channel;
return StreamBuilder<Map<String, dynamic>>(
stream: channel.extraDataStream,
initialData: channel.extraData,
builder: (context, snapshot) {
String image;
if (snapshot.data?.containsKey('image') == true) {
image = snapshot.data['image'];
} else if (channel.state.members.length == 2) {
final otherMember = channel.state.members
.firstWhere((member) => member.user.id != client.user.id);
image = otherMember.user.extraData['image'];
}
return ClipRRect(
borderRadius: StreamChatTheme.of(context)
.channelPreviewTheme
.avatarTheme
.borderRadius,
child: Container(
constraints: StreamChatTheme.of(context)
.channelPreviewTheme
.avatarTheme
.constraints,
constraints: constraints ??
StreamChatTheme.of(context)
.channelPreviewTheme
.avatarTheme
.constraints,
decoration: BoxDecoration(
color: StreamChatTheme.of(context).accentColor,
),
child: snapshot.data?.containsKey('image') ?? false
child: image != null
? CachedNetworkImage(
imageUrl: snapshot.data['image'],
imageUrl: image,
errorWidget: (_, __, ___) {
return Center(
child: Text(