1234567891011121314151617181920212223242526 |
- import 'package:flutter/material.dart';
- /// 页面缓存
- class KeepAliveWrapper extends StatefulWidget {
- final Widget child;
- const KeepAliveWrapper({Key? key, required this.child}) : super(key: key);
-
- @override
- _KeepAliveWrapperState createState() => _KeepAliveWrapperState();
- }
- class _KeepAliveWrapperState extends State<KeepAliveWrapper>
- with AutomaticKeepAliveClientMixin {
- @override
- bool get wantKeepAlive => true;
- @override
- Widget build(BuildContext context) {
- super.build(context);
- return widget.child;
- }
- }
|