diff --git a/example/lib/chat_info_screen.dart b/example/lib/chat_info_screen.dart index 5f7f7c63..53adebb7 100644 --- a/example/lib/chat_info_screen.dart +++ b/example/lib/chat_info_screen.dart @@ -381,12 +381,43 @@ class __SharedGroupsScreenState extends State<_SharedGroupsScreen> { }, ), builder: (context, snapshot) { - if (snapshot.data == null) { + if (!snapshot.hasData) { return Center( child: CircularProgressIndicator(), ); } + if (snapshot.data.isEmpty) { + return Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + StreamSvgIcon.message( + size: 136.0, + color: Color(0xffdbdbdb), + ), + SizedBox(height: 16.0), + Text( + 'No Shared Groups', + style: TextStyle( + fontSize: 14.0, + color: Color(0xff000000), + ), + ), + SizedBox(height: 8.0), + Text( + 'Group shared with User will appear here.', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 14.0, + color: Color(0xff000000).withOpacity(0.5), + ), + ), + ], + ), + ); + } + return ListView.builder( itemCount: snapshot.data.length, itemBuilder: (context, position) { diff --git a/example/lib/group_info_screen.dart b/example/lib/group_info_screen.dart index b4972165..5a2d4a7d 100644 --- a/example/lib/group_info_screen.dart +++ b/example/lib/group_info_screen.dart @@ -671,32 +671,34 @@ class _GroupInfoScreenState extends State { ); }), _buildModalListTile( - StreamSvgIcon.message( - color: Color(0xff7a7a7a), - size: 24.0, - ), - 'Message', () async { - var client = StreamChat.of(context).client; + StreamSvgIcon.message( + color: Color(0xff7a7a7a), + size: 24.0, + ), + 'Message', + () async { + var client = StreamChat.of(context).client; - var c = client.channel('messaging', extraData: { - 'members': [ - user.id, - StreamChat.of(context).user.id, - ], - }); + var c = client.channel('messaging', extraData: { + 'members': [ + user.id, + StreamChat.of(context).user.id, + ], + }); - await c.watch(); + await c.watch(); - await Navigator.push( - context, - MaterialPageRoute( - builder: (context) => StreamChannel( - channel: c, - child: ChannelPage(), + await Navigator.push( + context, + MaterialPageRoute( + builder: (context) => StreamChannel( + channel: c, + child: ChannelPage(), + ), ), - ), - ); - }), + ); + }, + ), if (!channel.isDistinct && StreamChat.of(context).user.id != user.id && isUserAdmin) diff --git a/lib/src/channel_file_display_screen.dart b/lib/src/channel_file_display_screen.dart index c8b34ea0..c319b524 100644 --- a/lib/src/channel_file_display_screen.dart +++ b/lib/src/channel_file_display_screen.dart @@ -15,9 +15,13 @@ class ChannelFileDisplayScreen extends StatefulWidget { /// message_limit: how many messages should be included to each channel final PaginationParams paginationParams; - ChannelFileDisplayScreen({ + /// The builder used when the file list is empty. + final WidgetBuilder emptyBuilder; + + const ChannelFileDisplayScreen({ this.sortOptions, this.paginationParams, + this.emptyBuilder, }); @override @@ -93,6 +97,9 @@ class _ChannelFileDisplayScreenState extends State { } if (snapshot.data.isEmpty) { + if (widget.emptyBuilder != null) { + return widget.emptyBuilder(context); + } return Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, @@ -101,19 +108,15 @@ class _ChannelFileDisplayScreenState extends State { size: 136.0, color: Color(0xffdbdbdb), ), - SizedBox( - height: 16.0, - ), + SizedBox(height: 16.0), Text( - 'No Media', + 'No Files', style: TextStyle( fontSize: 14.0, color: Color(0xff000000), ), ), - SizedBox( - height: 8.0, - ), + SizedBox(height: 8.0), Text( 'Files sent in this chat will appear here', textAlign: TextAlign.center, @@ -127,7 +130,7 @@ class _ChannelFileDisplayScreenState extends State { ); } - Map media = {}; + final media = {}; for (var item in snapshot.data) { item.message.attachments.where((e) => e.type == 'file').forEach((e) { diff --git a/lib/src/channel_media_display_screen.dart b/lib/src/channel_media_display_screen.dart index 41ec41b3..21eeb611 100644 --- a/lib/src/channel_media_display_screen.dart +++ b/lib/src/channel_media_display_screen.dart @@ -17,7 +17,14 @@ class ChannelMediaDisplayScreen extends StatefulWidget { /// message_limit: how many messages should be included to each channel final PaginationParams paginationParams; - ChannelMediaDisplayScreen({this.sortOptions, this.paginationParams}); + /// The builder used when the file list is empty. + final WidgetBuilder emptyBuilder; + + const ChannelMediaDisplayScreen({ + this.sortOptions, + this.paginationParams, + this.emptyBuilder, + }); @override _ChannelMediaDisplayScreenState createState() => @@ -92,6 +99,9 @@ class _ChannelMediaDisplayScreenState extends State { } if (snapshot.data.isEmpty) { + if (widget.emptyBuilder != null) { + return widget.emptyBuilder(context); + } return Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, @@ -100,9 +110,7 @@ class _ChannelMediaDisplayScreenState extends State { size: 136.0, color: Color(0xffdbdbdb), ), - SizedBox( - height: 16.0, - ), + SizedBox(height: 16.0), Text( 'No Media', style: TextStyle( @@ -110,9 +118,7 @@ class _ChannelMediaDisplayScreenState extends State { color: Color(0xff000000), ), ), - SizedBox( - height: 8.0, - ), + SizedBox(height: 8.0), Text( 'Photos or video sent in this chat will \nappear here', textAlign: TextAlign.center, @@ -126,7 +132,7 @@ class _ChannelMediaDisplayScreenState extends State { ); } - List<_AssetPackage> media = []; + final media = <_AssetPackage>[]; for (var item in snapshot.data) { item.message.attachments