dreampad/lib/app/shared/helpers/keep_alive_page.dart

26 lines
542 B
Dart
Raw Permalink Normal View History

2023-11-28 10:44:58 +08:00
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;
}
}