简体   繁体   English

Flutter beta hot reload in VSCode works for web but not iOS and Android (which works in Android studio)

[英]Flutter beta hot reload in VSCode works for web but not iOS and Android (which works in Android studio)

I'm running Mac Catalina and have both Android Studio and VSCode installed我正在运行 Mac Catalina 并安装了 Android Studio 和 VSCode

❯ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, 1.19.0-4.3.pre, on Mac OS X 10.15.5 19F101, locale en-GB)
 
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.0)
[✓] VS Code (version 1.47.0)
[✓] Connected device (3 available)

• No issues found!

I have a very simple app我有一个非常简单的应用程序

import 'package:flutter/material.dart';

void main() {
  runApp(
    MaterialApp(
      home: Center(
        child: Text("Hello World!"),
      ),
    ),
  );
}

If I run the app from Android Studio then hot reload works just fine, eg changing the text and saving will update the text on any of the devices (iOS, Android or Chrome).如果我从 Android Studio 运行应用程序,那么热重载就可以正常工作,例如更改文本并保存将更新任何设备(iOS、Android 或 Chrome)上的文本。

But if I do the same in VSCode, ie F5 ( Debug: Start debugging ), then hot reload only works for web.但是如果我在 VSCode 中做同样的事情,即 F5( Debug: Start debugging ),那么热重载仅适用于 web。 Looking in the debug console I see the following each time I make a change and save.每次进行更改并保存时,在调试控制台中都会看到以下内容。

Reloaded 1 of 502 libraries in 167ms.

But no updates on the screen (except when running Chrome where output in the debug console looks the same as with the others.).但是屏幕上没有更新(除了运行 Chrome 时,调试控制台中的 output 看起来与其他的相同。)。 I find this very odd!我觉得这很奇怪!

Update更新

I've opened a bug report at dart-code .我在dart-code打开了一个错误报告

Oh my.天啊。 I forgot to put the app inside a stateless app.我忘记将应用程序放入无状态应用程序中。 My mistake!我的错!

import 'package:flutter/material.dart';

void main() {
  runApp(
    MyApp(),
  );
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Center(
        child: Text("Hello World!"),
      ),
    );
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 热重载不起作用,但在 Android Studio 中热重启有效 - Hot reload doesn't work but hot restart works in Android Studio Android Studio Flutter热重载按钮不起作用 - Android studio Flutter hot reload button is not working Gradle配置不再适用于Android Studio 3(测试版) - Gradle config no longer works in Android Studio 3 (beta) Flutter web 共享图像适用于 windows 但不适用于 android/ios - Flutter web sharing image works on windows but not on android/ios 为什么热重载在 Flutter 中可用,而在本机 Android 或 iOS 中不可用? - Why hot reload is available in Flutter and not in native Android or iOS? Admob广告无法在Android上显示,但可以在iOS上使用-Flutter - Admob Ads not showing on Android but works on iOS — Flutter Flutter - FutureBuilder 在 Android 上运行良好,但在 iOS 上运行不佳 - Flutter - FutureBuilder works well on Android but not well on iOS Flutter 程序可在 Web 上运行,但不能在 Android 设备上运行 - Flutter Program Works on Web but Not Running on Android Device Flutter 音频播放器在 android 上完全没有声音,但在 web 上有效 - Flutter audioplayers no sound at all on android but works on web Firebase updateChildValues可在IOS中使用,但不适用于Web和Android - Firebase updateChildValues works in IOS but not in Web and Android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM