本文介绍了如何清除 Flutter 的 Build 缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

flutter 的构建似乎有问题.

每次我在模拟器或设备上运行应用程序时,我总是需要执行 RUN > Flutter Full Restart.

否则,该应用程序会加载一个脚手架主体,这是我的代码在 2 周前第一次开始编码时使用的.

我猜 Flutter 已经缓存了旧代码并且从不费心用新代码替换它,但我不确定它的 Hot Reload 是如何实现的.无论如何,我认为没有必要在我们已经执行完完整重建后加载旧缓存.

解决方案

你可以运行flutter clean.

但这很可能是您的 IDE 或类似产品的问题,因为 flutter run 会创建一个全新的 apk.并且热重载仅推送修改.

尝试使用命令行 flutter run 运行您的应用,然后按 rR 分别进行热重载和完全重载.

There seems to be a problem with flutter's build.

I always need to perform RUN > Flutter Full Restart everytime I run the app to an emulator or device.

Otherwise, the app loads a scaffold body which my code had from 2 weeks ago when I first started coding it.

Here's the current source on pastebin

children: <Widget>[
          new Opacity(
              opacity: loader_visible ? 1.0 : 0.0,
              child:
              new Container(
                  padding: const EdgeInsets.all(32.0),
                  child: new CircularProgressIndicator()
              )
          ),

while here is the resulting render tree:

I'm guessing flutter has cached the old code and never bothered replacing it with the new one, but I am not sure how it's Hot Reload was implemented. Anyways, I don't think that it is necessary to load the old cache when we have already performed a full rebuild.

解决方案

You can run flutter clean.

But that's most likely a problem with your IDE or similar, as flutter run creates a brand new apk. And hot reload push only modifications.

Try running your app using the command line flutter run and then press r or R for respectively hot-reload and full-reload.

这篇关于如何清除 Flutter 的 Build 缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 00:49