I have a setting screen, when I change FontFamily it needs to restart the app to change all app fonts, And it restarts after the app closed, but I want to restart the app with a button instead of closing the app. does there any way to do this ?
-
Hello - which IDE are you using ? VsCode ? Android Studio ? Are you running using debug mode ?Aristidios– Aristidios2021-07-23 20:49:27 +00:00Commented Jul 23, 2021 at 20:49
-
Iam using VsCode and running with debug modeuser14742245– user147422452021-07-23 21:40:34 +00:00Commented Jul 23, 2021 at 21:40
-
Here you will find your answer stackoverflow.com/questions/50115311/…ahmed-m-abdelfatah– ahmed-m-abdelfatah2021-07-24 02:05:57 +00:00Commented Jul 24, 2021 at 2:05
-
Does this answer your question? Flutter: how to force an application restart (in production mode)?Jannie Theunissen– Jannie Theunissen2022-03-03 06:18:05 +00:00Commented Mar 3, 2022 at 6:18
Add a comment
|
3 Answers
The best solution... using "Restart App" module
- Instal from your teminal:
flutter pub add restart_app
- Import from your dart file:
import 'package:restart_app/restart_app.dart';
- Call "Restart App" from your Button:
onPressed: () { Restart.restartApp();}
Have a nice day...
1 Comment
Hossein Yousefpour
Just as an update, the package is updated to v1.2.0 and now it supports iOS as well.
Use this package https://pub.dev/packages/flutter_phoenix and call Phoenix.rebirth(context); when you want to reload the app
1 Comment
Community
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
I have implemented the https://pub.dev/packages/flutter_phoenix package in my app, to restart the app wrap widget with Phoenix on the line of code:
runApp(Phoenix(child: MyApp()))
wherever you want to restart the app just implement this line of code
Phoenix.rebirth(context);
hope this help