给Statae添加AutomaticKeepAliveClientMixin
例:
class xxxPage extends StatefulWidget {
const xxxPage({Key? key}) : super(key: key);
@override
_xxxPageState createState() => _xxxPageState();
}
class _xxxState extends State<TrainingCampListPage> with AutomaticKeepAliveClientMixin {
// TODO: implement wantKeepAlive
@override
bool get wantKeepAlive => true;
}
如此便可。