From 96c99f02bde93e80214bfbb94a92ebbc86fd53a1 Mon Sep 17 00:00:00 2001 From: linwenlong Date: Mon, 17 Jun 2019 16:23:06 +0800 Subject: [PATCH] fix the bug: when changes state and widget, but state reuse, the new ui won't update. --- lib/flutter_built_redux.dart | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/flutter_built_redux.dart b/lib/flutter_built_redux.dart index 09bb9b7..1ed9268 100644 --- a/lib/flutter_built_redux.dart +++ b/lib/flutter_built_redux.dart @@ -145,6 +145,18 @@ class _StoreConnectorState @override Widget build(BuildContext context) => widget.build(context, _state, _store.actions as Actions); + + @mustCallSuper + @protected + void didUpdateWidget(StoreConnector oldWidget) { + super.didUpdateWidget(oldWidget); + final newState = widget.connect(_store.state as StoreState); + if (_state != newState) { + setState(() { + _state = newState; + }); + } + } } /// [ReduxProvider] provides access to the redux store to descendant widgets.