mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
28 lines
624 B
Dart
28 lines
624 B
Dart
import 'package:flutter/material.dart';
|
|
|
|
class KeepAliveWrapper extends StatefulWidget {
|
|
const KeepAliveWrapper({
|
|
super.key,
|
|
required this.builder,
|
|
this.wantKeepAlive = true,
|
|
});
|
|
|
|
final WidgetBuilder builder;
|
|
final bool wantKeepAlive;
|
|
|
|
@override
|
|
State<KeepAliveWrapper> createState() => _KeepAliveWrapperState();
|
|
}
|
|
|
|
class _KeepAliveWrapperState extends State<KeepAliveWrapper>
|
|
with AutomaticKeepAliveClientMixin {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
super.build(context);
|
|
return widget.builder(context);
|
|
}
|
|
|
|
@override
|
|
bool get wantKeepAlive => widget.wantKeepAlive;
|
|
}
|