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.
Related
Hello I'm editing someone codes in Flutter using VS code, how can I easily find on what on I am running on my emulator. for example i am showing log in screen in the emulator. how can I know what filename did I need to edit.
as of now I am trying to check one by one of the codes. I tried to use widget tree but it is now updating
You can use the widget tree field in flutter devtool. Navigate to the desired page in the emulator and click the refresh button at the top right. The running widget stack will be listed by class names.
You can even detect a specific widget on the page using the "Choose widget mode" button.
Install and run DevTools from VS Code
I created a flutter webview, but when I try to go back to the previous page the app closes. How can I activate the back key on the phone? I would like to use the phone key without adding any more. I thought about using Onbackpressed but in flutter it is not possible. Or you can use Willpopscope () but it doesn't work for me, someone help me please!!
You need to put your app in scaffold and implement onWillPop feature for scaffold.
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.
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.
I have a page that presents chat messages and has the dates of a group of messages as a divider in my flutter app. The data is pulled from localDB and I am trying to make it refresh the data by polling the DB for updates, however everytime I rebuild the stream or even future it makes the screen flicker and it automatically scrolls to the top of the list. The code is too big for here so I have posted it here.
It uses a Stream builder that calls a widget with data it gets from the first stream and uses another streambuilder to build the messages. I am sure this has something to do with it, but have no idea how to change that or fix the flicker and scroll weirdness.
Hoping someone has some ideas of how to handle this better or fix the flickering.
What you could try is creating a "app state" for each page, for example:
Loading app state - which displays a Progress Indicator when you're polling from DB/server.
Success app state - this dismisses the Progress Indicator and just shows an empty container, displaying your data.
Failed app state - Displays an error icon of your choice.
Perhaps you could try this library, Flutter GetX , and I recommend this library because of how simple it is to use.
It has state management library, which saved me lots of time and code using streams and setState({}).