Problem with easy_localization in flutter_bloc - flutter

I am trying to use easy_localization in my app and my state management in bloc. Everything working fine till I change the language. It is not changing all texts I need. It is changing half of the texts and stopping. It is only changing after hot reload. I have tried to rebuild bloc and it did not help me.

Related

Flutter - How to preserve widgets with data and states, when navigating using the NavigationBar class

I'm using the NavigationBar class for the navigation through my app, but I have a problem, which is that I can't preserve the information on the screen when I'm navigating, so everything loads up again at the start of the screen. How should I do to preserve the screen even if I am in another screen so everything doesnt load up again?
You can use bloc for your state management.
Use states. There are a lot of options available like for example stateful widgets.

Will all widgets, children of IndexedStack, initial simultaneously?

I am using IndexedStack for BottomNavigationBar to prevent pages initial every time I change tab.
However, it seems that there is another problem about pages initailization. I find all pages will initial at the time. Is that true?
If so, how can I solve it?
Oh, I have already solved this problem. Just using PageView instead of IndexedStack. If you don't wanna rebuild page every time you tab into. Let pages' state with AutomaticKeepAliveClientMixin, and IDE will make you know what to do to work.

How can I see when a Widget rebuilds?

Code source
Is there any trick to know that a widget has been rebuilt?
As a demonstration, i.e. if we randomly colored the widgets on every rebuild, it would look like this:
Flutter actually has built-in functionality for exactly what you are trying to achieve in the DevTools inspector:
This is called the Repaint Rainbow and it can be enabled in Android Studio, i.e. IntelliJ, as demonstrated above or directly in Dart DevTools:
Repaint Rainbow
Shows rotating colors on layers when repainting.
From the linked article
Notes
There can be many reasons for repaints and seeing a widget rebuild does not inherently mean that you triggered the rebuild as it can also come from somewhere else in the tree.
You cannot know if a widget has been rebuilt in code because that is against how the framework works - you can obviously catch any build or paint calls by integrating that into your build or paint function, but you should really not do that because builds and paints should be idempotent.
If you use android studio you can open Flutter Performance and checked Track widgets rebuild in Widget rebuild stats
Every time the widgets are rebuild ,the build() is called So You can write a print() in your build() and track when the widgets are getting rebuilt
You can't know it, and should not build a word around to obtain that value yourself either.
This is anti pattern, as the number of times a widget rebuilt should never have an impact on the output.

Flutter hot reload not working in android studio

When I comment on New Text ('41 ') and then I press HOT RELOAD but it doesn't change, I've pressed a lot it hasn't changed, then I press the RUN button then it works fine
Anyone got the same problem?
enter image description here
Make sure you are using a stateless or stateful widget, the hot reload/refresh only works when you are dealing with state.
If you just run your main class without any state Widget, you'll have to run the application each time that you want to test a new modification.

Attempting to hot reload Flutter app restarts whole app

I'm working on a Flutter app and I've noticed that whenever I save my app to see the updated changes, my entire app reloads. I would expect the page that I have open to hot reload with my new changes on it.
I think that the way my widget tree is organised could have an effect on this. My entire app is wrapped in a widget that runs at startup that initialises to a ServicesLoadingState. Then, after the services have finished starting up (in the BLoC), it yields a ServicesReadyState and then all my widgets are drawn. I think when I hot reload, the state of the topmost widget switches back to ServicesLoadingState, reloads the services, and shows me the behaviour I'm experiencing.
I've tried googling "flutter hot reload restarts app" but I haven't found any good tips on how to prevent this. How can I stop hot reload from restarting the entire app?
Can you check if you are using a global navigatorKey in your MaterialApp ?
I faced the same issue and I found that it was due to navigatorKey in my MaterialApp.
So when I'm in dev mode, I comment the navigatorKey property.