简体   繁体   English

Flutter web:“webdev build”时出现黑屏

[英]Flutter web: blank screen when 'webdev build'

I made a webpage with flutter web.我用 flutter web 做了一个网页。 I tested it with the command我用命令测试了它

webdev serve

I can see the whole website,我可以看到整个网站,

But when I want to 'export / save' the website with this command:但是当我想用这个命令“导出/保存”网站时:

webdev build

The webpage is blank, (when I open the html file in the build folder)网页是空白的,(当我打开构建文件夹中的 html 文件时)

[INFO] Reading cached asset graph completed, took 245ms
[INFO] Checking for updates since last build completed, took 806ms
[INFO] Running build completed, took 217ms
[INFO] Caching finalized dependency graph completed, took 148ms
[INFO] Reading manifest at build/.build.manifest completed, took 1ms
[INFO] Deleting previous outputs in `build` completed, took 45ms
[INFO] Creating merged output dir `build` completed, took 226ms
[INFO] Writing asset manifest completed, took 4ms
[INFO] Succeeded after 671ms with 0 outputs (0 actions)

Thanks in advance!提前致谢!

UPDATE:更新:

If I open the html file in the build folder (that gives a blank screen).如果我在构建文件夹中打开 html 文件(这会给出一个空白屏幕)。 These are my errors in the console of google chrome:这些是我在谷歌浏览器控制台中的错误:

错误flutterweb

I have a same issue but when I upload live server(host) it worked correctly.我有同样的问题,但是当我上传实时服务器(主机)时它工作正常。 I am not sure but it can be about CORS, browser not allowed some source coming from outside of website so in local files has local source that means they are coming from outside the website as browser views.我不确定,但可能与 CORS 相关,浏览器不允许来自网站外部的某些来源,因此在本地文件中具有本地来源,这意味着它们作为浏览器视图来自网站外部。 I think you should upload live server or local server.我认为您应该上传实时服务器或本地服务器。

My flutter web app was displaying a blank page / blank screen too...我的 flutter web 应用程序也显示空白页/空白屏幕...

Try running the following in the terminal:尝试在终端中运行以下命令:

  • flutter channel dev
  • flutter upgrade
  • flutter run -d chrome

If it still shows you a blank page (because it's not reaching your local server for some reason) terminate the current server 'ctrl + c'.如果它仍然显示一个空白页面(因为由于某种原因它没有到达您的本地服务器)终止当前服务器'ctrl + c'。

Then run flutter run -d web and the terminal will provide you with a new local host url.然后运行flutter run -d web终端将为您提供一个新的本地主机 url。 Follow the link and refresh it once & you should see your app running.点击链接并刷新一次,您应该会看到您的应用正在运行。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM