Files
MWClash/lib/widgets/keep_scope.dart

28 lines
541 B
Dart
Raw Normal View History

2024-04-30 23:38:49 +08:00
import 'package:flutter/material.dart';
class KeepScope extends StatefulWidget {
2024-04-30 23:38:49 +08:00
final Widget child;
final bool keep;
2024-04-30 23:38:49 +08:00
const KeepScope({
super.key,
required this.child,
this.keep = true,
});
2024-04-30 23:38:49 +08:00
@override
State<KeepScope> createState() => _KeepContainerState();
2024-04-30 23:38:49 +08:00
}
class _KeepContainerState extends State<KeepScope>
2024-04-30 23:38:49 +08:00
with AutomaticKeepAliveClientMixin {
@override
Widget build(BuildContext context) {
super.build(context);
return widget.child;
}
@override
bool get wantKeepAlive => widget.keep;
2024-04-30 23:38:49 +08:00
}