From 16eb9bd397fcbcc6d8527108940fa5c1d310c2c3 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Mon, 24 Aug 2020 11:07:32 +0200 Subject: [PATCH] implement didUpdateWidget in ChannelListView to react to setState --- lib/src/channel_list_view.dart | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/src/channel_list_view.dart b/lib/src/channel_list_view.dart index 61b557b6..231e1ba9 100644 --- a/lib/src/channel_list_view.dart +++ b/lib/src/channel_list_view.dart @@ -352,10 +352,9 @@ class _ChannelListViewState extends State void initState() { super.initState(); - final channelsBloc = ChannelsBloc.of(context); - WidgetsBinding.instance.addObserver(this); + final channelsBloc = ChannelsBloc.of(context); channelsBloc.queryChannels( filter: widget.filter, sortOptions: widget.sort, @@ -390,6 +389,24 @@ class _ChannelListViewState extends State }); } + @override + void didUpdateWidget(ChannelListView oldWidget) { + super.didUpdateWidget(oldWidget); + + if (widget.filter != oldWidget.filter || + widget.sort != oldWidget.sort || + widget.pagination != oldWidget.pagination || + widget.options != oldWidget.options) { + final channelsBloc = ChannelsBloc.of(context); + channelsBloc.queryChannels( + filter: widget.filter, + sortOptions: widget.sort, + paginationParams: widget.pagination, + options: widget.options, + ); + } + } + @override void dispose() { WidgetsBinding.instance.removeObserver(this);