Flutter Hot Reload and Hot Restart do not always work
Asked Answered
M

6

6

For now one week, sometimes when I HotReload my changes are not applied (the log says it's been HotReload but in fact, they are not) and the same when I HotRestart so I'm forced to stop and re-run the app (and sometimes to delete the build)!

    Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel beta, v1.15.17, on Microsoft Windows [version 10.0.17763.1098], locale fr-FR)

[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[√] Chrome - develop for the web
[√] Android Studio (version 3.6)
[√] Connected device (3 available)

• No issues found!

I run my app on Android Emulator 9 Pie.

EDIT: I tried to invalidate the cache of AndroidStudio and restart, and also tried on another emulator but it didn't solve the issue...

Matherly answered 27/3, 2020 at 19:38 Comment(8)
This may be tricky because of the hot reload may depend on the context. For instance, if you have a listen over a stream in the initState of a State class, the initState is not called again on hot reload. For the hot restart, I never have problems, so I can not help there.Lohner
This sounds more like an IDE issue? Which one you use and what OS?Tombola
all is in my Flutter Doctor Log, I'm on windows and I use Android StudioMatherly
if you add new dependencies into yaml file, then hot reload/restart will not work. You should stop and run the project again. Otheriwise hot restart will work for all scanario and hot reload will work for build method changes and non static pure dart changes.Cryology
had you tried hot reloading or hot restarting after flutter clean and yeah I guess you are working with flutter web which is in beta at the moment which might be the problem.Wanonah
@Cryology oh yes it should but as I sayd it don't.Matherly
@ChinkySight a flutter clean will not change anything to HotReload or Restart because Flutter clean delete the build and the principle of HotRestart/Reload is to do not rebuild the project to gain time... The fact Flutter Web is in Beta was a good idea but I removed the Web support and the issue still here :(Matherly
Does this happen for all your projects or just one? Have you tried to create a project from scratch, with nothing in there and test?Lanita
M
8

My problem was a bad import

import 'file:///C:/Users/plest/StudioProjects/the_spot/lib/pages/home_page/Map/map.dart' ;

instead of

import 'package:the_spot/pages/home_page/Map/map.dart' ;

I don't know why the import changed by itself...

Matherly answered 31/3, 2020 at 16:51 Comment(2)
This worked perfectly for me, I waste my 1 hour on this stupid problem. ThanksGarbage
i'm just on hello world project and this is happening!Eroticism
F
1

try changing your channel, for example run flutter channel master . worked for me

Felodese answered 29/8, 2021 at 22:21 Comment(2)
It's working for me with below scenario, once change the channel, also check your version also. If it is old just upgrade your flutter version. >$flutter upgradeIcily
Not working for me. I also run flutter upgrade.Favourite
K
0

uninstall & after re-install flutter plugin from setting will make this right

Kirkpatrick answered 1/6, 2021 at 12:20 Comment(0)
S
0

After installation. I rebooted my mac and suddenly it was way faster!

Syndicate answered 17/10, 2021 at 12:0 Comment(0)
V
0

It could be a proxy problem. Please try to close it.

Vella answered 7/4, 2022 at 14:53 Comment(0)
H
0

I was having same problem, after trying long time then realised that it was happening because I named my project using arabic characters. Changed back to english named folder and the reload worked like a charm..

Heterodyne answered 20/7, 2023 at 12:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.