Merge pull request #135 from GetStream/nash/empty-state

Expose builder for empty channel state
This commit is contained in:
Salvatore Giordano
2020-11-16 10:07:50 +01:00
committed by GitHub
+9 -1
View File
@@ -63,6 +63,7 @@ class ChannelListView extends StatefulWidget {
this.channelPreviewBuilder,
this.separatorBuilder,
this.errorBuilder,
this.emptyBuilder,
this.onImageTap,
this.pullToRefresh = true,
}) : super(key: key);
@@ -70,6 +71,9 @@ class ChannelListView extends StatefulWidget {
/// The builder that will be used in case of error
final Widget Function(Error error) errorBuilder;
/// The builder used when the channel list is empty.
final WidgetBuilder emptyBuilder;
/// The query filters to use.
/// You can query on any of the custom fields you've defined on the [Channel].
/// You can also filter other built-in channel fields.
@@ -231,7 +235,11 @@ class _ChannelListViewState extends State<ChannelListView>
final channels = snapshot.data;
if (channels.isEmpty) {
if (channels.isEmpty && widget.emptyBuilder != null) {
return widget.emptyBuilder(context);
}
if (channels.isEmpty && widget.emptyBuilder == null) {
return LayoutBuilder(
builder: (context, viewportConstraints) {
return SingleChildScrollView(