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

父级页面更新状态无法重新触发PageView子页面更新 #614

Open charmfocus opened 4 years ago

charmfocus commented 4 years ago

有父页面GoodsPage,PageView.builder来做tab切换的列表页面,包含了GoodsListPage页面,


PageView.builder(
                      key: const Key('pageView'),
                      itemCount: state.tabsData.length,
                      onPageChanged: (int index) {
                        state.tabController.animateTo(index);
                        dispatch(
                            GoodsActionCreator.updateTabIndexAction(index));
                      },
                      controller: state.pageController,
                      itemBuilder: (_, int index) {
                        var param = GoodsListPageParam(
                          index: index,
                          categoryId: state.category?.id,
                          status: state.tabsData[index].status,
                        );
                        return GoodsListPage().buildPage(param);
                      },
                    ),

父页面有更改state.category.id的功能,想把categoryId同步到GoodsListPage,GoodsListPage页面是用initState来接收的,似乎页面第一次初始化才能被调用initState,第二次更新状态时,无法调用initState,这种情况GoodsListPage如何接收新的状态? @zjuwjf

xinpiaoyuanfang commented 4 years ago

effect里 Lifecycle.didChangeDependencies? 可以试一下

bhjSky commented 4 years ago

@charmfocus 请问解决了吗?同样遇到了父页面更新, 无法触发子页面更新

beydeng commented 4 years ago

@charmfocus 我这边遇见的问题是,如indexpage里面的child中放入多个page,如homePage,我发现indexPage initstate之后,homePage的initState不会运行,导致homePage的state无法实例化,这是什么原因导致的。感觉和你的类似,请教一下,谢谢。