答案 0 :(得分:0)
您可以尝试另一种在页面中保持状态的方法:
// 1. AutomaticKeepAliveClientMixin
class _PageState extends State<_HomePage> with AutomaticKeepAliveClientMixin<_HomePage> {
// 2.
@override
bool get wantKeepAlive => true;
@override
Widget build(BuildContext context) {
//3.
super.build(context);
return Scaffold(...
);
}
}