VSCode hot reload for Flutter does not work

后端 未结 14 1169
野性不改
野性不改 2021-01-11 11:50

I\'m on VSCode right now working on my flutter application when hot reload just stops working, right in the middle of my development. I have absolutely no idea why this happ

相关标签:
14条回答
  • 2021-01-11 12:13

    For me on the latest VS studio, pressing CRTL+s does the hot reload nicely for me. kinda a habbit from other IDE's.

    0 讨论(0)
  • 2021-01-11 12:14

    This appears to be a vscode issue in version 1.32.1 - see https://github.com/flutter/flutter/issues/29275 and https://github.com/Dart-Code/Dart-Code/issues/1518

    In the meantime, you could revert to 1.31, wait for a fix in the next version, install the insiders version (which includes a fix), or could use 'flutter run' from the vscode terminal.

    0 讨论(0)
  • 2021-01-11 12:14

    If you're implementing your MaterialApp in main.dart will cause this issue, the best practice is to separate out another dart file, then refer from main.dart.

    0 讨论(0)
  • 2021-01-11 12:22

    The hot reload doesn't work if you launch your app using f5 or select start debugging from the dropdown of debug .

    But if you launch your app using Ctrl+f5 or select start without debugging from the dropdown of debug .

    To solve the issue first close the running debugging session using Shift+f5.

    Then click debug from the menu bar. Click Start without debugging.

    Now The Hot reload works perfectly fine.

    You can do the hot reload also using terminal. Just type: flutter run in the terminal and the app will be launched.

    just press r in the terminal and hot reload will be initialized.

    0 讨论(0)
  • 2021-01-11 12:23

    I had the same problem. Currently I am using VSCode version 1.39.2.

    For the hot reload to work you need to start debugging in VSCode.

    As it says in the docs: "Only Flutter apps in debug mode can be hot reloaded." https://flutter.dev/docs/development/tools/hot-reload

    You can find that option on the VSCode's top navigation inside Debug or with the shortcut F5.

    You don't need to do flutter run on your terminal, nor even on VSCode, is just start debugging and it will launch lib/main.dart in debug mode.

    If that doesn't solve the problem, try downgrading to the last version of VSCode.

    0 讨论(0)
  • 2021-01-11 12:24

    Make sure you don't have this type of imports I was going crazy and deleting them fixed the hot reload, check all your files, I found this answer in github: https://github.com/flutter/flutter/issues/49744

    import file:///C:/Users/.../.../< App Name >/lib/filename.dart

    0 讨论(0)
提交回复
热议问题