import 'package:flutter/cupertino.dart'; class WantKeepAlive extends StatefulWidget { final Widget child; WantKeepAlive({required this.child}); @override State createState() { return WantKeepAliveState(); } } class WantKeepAliveState extends State with AutomaticKeepAliveClientMixin { @override Widget build(BuildContext context) { super.build(context); return widget.child; } @override bool get wantKeepAlive => true; }