import 'package:flutter/material.dart'; ///页面保活方法 class KeepAlivePage extends StatefulWidget { final Widget child; const KeepAlivePage({Key? key, required this.child}) : super(key: key); @override State createState() { return _KeepAliveState(); } } class _KeepAliveState extends State with AutomaticKeepAliveClientMixin { @override bool get wantKeepAlive => true; @override Widget build(BuildContext context) { super.build(context); return widget.child; } }