flutterdartstate-managementflutter-blocequatable

Flutter BloC NOT re-building after using multiblocprovider


I am using flutter BloC .

I Have Two block need to be applied to the app (Theme and Language).

I used MultiBlocProvider with Builder to clear the code as possible.

The problem is when I press the buttons in Localization Screen & The Theme Screen The App NOT Re-Build

but when I restart the app, I found the state I pressed is stored in shared preference

Example The Current State is dark Theme, I press The Light Theme Button, the app is still in dark theme, When I re-started the app, It's is opened in Light Theme.

How can I Solve this problem

I Uploaded the code to GitHub on the following Link

https://github.com/MaxJan2010/flutter_bloc_starting_project

Can anybody help?


Solution

  • The problem that I forgot to pass the variables of appThemeType & languageCode

    So, overriding the props was the solution

    In localization state:

    @override
    
    List<Object> get props => [languageCode??''];
    

    https://github.com/MaxJan2010/flutter_bloc_starting_project/blob/ed2c632d708bb74438290c87168990c88be02d2c/lib/logic/utility/app_localization/localization_state.dart#L24

    also here in theme state

      @override
    
      List<Object> get props => [appThemeType??''];
    

    https://github.com/MaxJan2010/flutter_bloc_starting_project/blob/ed2c632d708bb74438290c87168990c88be02d2c/lib/logic/utility/app_theme/app_theme_state.dart#L21C1-L22C48