【发布时间】:2022-01-09 16:44:37
【问题描述】:
在我的应用主页中,我调用了一个 ScoreListPageBody,当我从另一个页面 (SettingsPage) 更改区域设置时,它会重新构建。
为了强制重建它,它包含一个 StreamBuilder,当区域设置更改并且用户返回主页时触发(使用 Navigator.push(....).then(() => triggerStream())) .
当我在主页中执行此操作时效果很好:
return Scaffold(
appBar: MenuAppBar(),
body: PageView(
controller: this._pageController,
children: [
ScoreListPageBody(),
FavoritesListPageBody(),
],
)
);
但这会阻止 ScoreListPageBody 的 StreamBuilder 的重建:
return Scaffold(
appBar: MenuAppBar(),
body: PageView(
controller: this._pageController,
children: const [
ScoreListPageBody(),
FavoritesListPageBody(),
],
)
);
我不明白为什么,因为 const 修饰符不应该影响 StreamBuilder 的行为,对吧?
所以,它可以在没有 const 的情况下工作,但是向 Flutter 团队报告是个问题吗?
【问题讨论】: