fish-redux icon indicating copy to clipboard operation
fish-redux copied to clipboard

BottomNavigationBar调用点击方法的时候,下面BottomNavigationBarItem如何改变为选中状态

Open hugolubingshen opened this issue 5 years ago • 1 comments
trafficstars

如题,我在BottomNavigationBar调用了一个点击方法,代码如下 bottomNavigationBar: BottomNavigationBar( backgroundColor: Colors.white, unselectedItemColor: Colors.black54, elevation: 1, selectedItemColor: Colors.deepOrange, type: BottomNavigationBarType.fixed, onTap: (currentIndex) { dispatch(EntranceActionCreator.onChangeIndexAction(currentIndex)); },

Action: static Action onChangeIndexAction(int index) { return Action(EntranceAction.changeIndexAction, payload: index); }

Effect: void _onChangeIndexAction(Action action, Context<EntranceState> ctx) { println("buildEffect---changeIndex"); int selectedIndex = action.payload; ctx.state.mainPageController.jumpToPage(selectedIndex); }

Reducer: EntranceState _onAction(EntranceState state, Action action) { final EntranceState newState = state.clone(); newState.selectedIndex = action.payload; return newState; } 打过断点,应该是没刷新,请问需要如何解决

hugolubingshen avatar May 22 '20 03:05 hugolubingshen

reducer 没有被执行。所以不会rebuid。

dddrop avatar May 22 '20 09:05 dddrop