Open hugolubingshen opened 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)); },
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); }
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); }
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; } 打过断点,应该是没刷新,请问需要如何解决
EntranceState _onAction(EntranceState state, Action action) { final EntranceState newState = state.clone(); newState.selectedIndex = action.payload; return newState; }
reducer 没有被执行。所以不会rebuid。
如题,我在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; }
打过断点,应该是没刷新,请问需要如何解决