24 lines
571 B
Dart
24 lines
571 B
Dart
![]() |
/// 封装缓存页面组件
|
||
|
library;
|
||
|
|
||
|
import 'package:flutter/material.dart';
|
||
|
|
||
|
class KeepAliveWrapper extends StatefulWidget {
|
||
|
final Widget child;
|
||
|
const KeepAliveWrapper({super.key, required this.child});
|
||
|
|
||
|
@override
|
||
|
State<KeepAliveWrapper> createState() => _KeepAliveWrapperState();
|
||
|
}
|
||
|
|
||
|
class _KeepAliveWrapperState extends State<KeepAliveWrapper> with AutomaticKeepAliveClientMixin {
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
super.build(context);
|
||
|
return widget.child;
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
bool get wantKeepAlive => true;
|
||
|
}
|