yes there is a way to do it. you have to do full restart (now it's called Hot Restart) in the code, the way to do it is to put your App inside a static widget(why static? because it'll be created once just to avoid the null or anything like that). and when you want to do full restart, just perform a hot-reload in that widget, after that it'll restart your app. you can use it from everywhere
here is the way :
1- first in main.dart, put the your App inside the Restart widget :
import 'package:flutter/material.dart';
import 'home.dart';
void main() {
runApp(new HotRestartController(
child: new MyApp()
));
}
2- write your hotRestartController inside the file :
class HotRestartController extends StatefulWidget {
final Widget child;
HotRestartController({this.child});
static performHotRestart(BuildContext context) {
final _HotRestartControllerState state = context.ancestorStateOfType(const TypeMatcher<_HotRestartControllerState>());
state.performHotRestart();
}
@override
_HotRestartControllerState createState() => new _HotRestartControllerState();
}
class _HotRestartControllerState extends State<HotRestartController> {
Key key = new UniqueKey();
void performHotRestart() {
this.setState(() {
key = new UniqueKey();
});
}
@override
Widget build(BuildContext context) {
return new Container(
key: key,
child: widget.child,
);
}
}
3- anytime, anywhere you can import the main.dart, and call "performHotRestart" using:
HotRestartController.restartApp(context)
have fun !