Home > Software engineering >  flutter : how to rebuild all the qpp after change the current language
flutter : how to rebuild all the qpp after change the current language

Time:01-24

rebuild the app after do something like change the theme or change the current language , iam using the ( easy_localization: ^3.0.0 ) package to change the lang EasyLocalization( child: MyApp(currentMode: currentMode), supportedLocales: const [ Locale('ar'), Locale('en'), ], path: 'assets/translations', startLocale: const Locale('ar'), assetLoader: const CodegenLoader(), ),

CodePudding user response:

If you're looking for the solution to this problem, this one works perfectly(tested) !

  1. Add the package phoenix from here
  2. Wrap your main widget with Phoenix

void main() {
  runApp(
    Phoenix(
      child: App(),
    ),
  );
}

  1. Call rebirth method anywhere in your app like so Phoenix.rebirth(context);

CodePudding user response:

Or make use of state management solutions like riverpod.

You place your settings in a provider and watch it on the pages that should change when the state updates.

  •  Tags:  
  • Related