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