4

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 Jul 23 '21 at 20:49
  • Iam using VsCode and running with debug mode –  Jul 23 '21 at 21:40
  • Here you will find your answer https://stackoverflow.com/questions/50115311/flutter-how-to-force-an-application-restart-in-production-mode – ahmed-m-abdelfatah Jul 24 '21 at 02:05
  • Does this answer your question? [Flutter: how to force an application restart (in production mode)?](https://stackoverflow.com/questions/50115311/flutter-how-to-force-an-application-restart-in-production-mode) – Jannie Theunissen Mar 03 '22 at 06:18

3 Answers3

5

The best solution... using "Restart App" module

  1. Instal from your teminal:

flutter pub add restart_app

  1. Import from your dart file:

import 'package:restart_app/restart_app.dart';

  1. Call "Restart App" from your Button:

onPressed: () { Restart.restartApp();}

Have a nice day...

Sapto Sutardi
  • 326
  • 4
  • 11
0

Use this package https://pub.dev/packages/flutter_phoenix and call Phoenix.rebirth(context); when you want to reload the app

  • 2
    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](/help/how-to-answer). – Community Apr 14 '22 at 01:29
0

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

J.Jayus
  • 1
  • 1