alibaba / fish-redux

An assembled flutter application framework.
https://github.com/alibaba/fish-redux
Apache License 2.0
7.33k stars 843 forks source link

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

Open hugolubingshen opened 4 years ago

hugolubingshen commented 4 years ago

如题,我在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; } 打过断点,应该是没刷新,请问需要如何解决

dddrop commented 4 years ago

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