34 lines
720 B
Dart
34 lines
720 B
Dart
// lib/ui/widgets/restart_widget.dart
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
class RestartWidget extends StatefulWidget {
|
|
final Widget child;
|
|
|
|
const RestartWidget({Key? key, required this.child}) : super(key: key);
|
|
|
|
static void restartApp(BuildContext context) {
|
|
context.findAncestorStateOfType<_RestartWidgetState>()?.restartApp();
|
|
}
|
|
|
|
@override
|
|
_RestartWidgetState createState() => _RestartWidgetState();
|
|
}
|
|
|
|
class _RestartWidgetState extends State<RestartWidget> {
|
|
Key key = UniqueKey();
|
|
|
|
void restartApp() {
|
|
setState(() {
|
|
key = UniqueKey();
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return KeyedSubtree(
|
|
key: key,
|
|
child: widget.child,
|
|
);
|
|
}
|
|
} |