dreampad/lib/app/shared/helpers/keep_alive_page.dart
2023-11-28 10:45:09 +08:00

26 lines
542 B
Dart

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