我创建了一个 flutter web
项目,它使用网络图像和 Assets 图像,在我的电脑上调试时一切正常,但是当我将它部署到网络服务器时,网络图像工作正常,但 Assets 图像根本不显示。当我在 Web 浏览器控制台中检查页面时,出现以下错误:
$1 @ window.dart:120
/assets/slack.png:1 Failed to load resource: the server responded with a status of 503 ()
window.dart:120 Error while trying to load an asset: Failed to load asset at "assets/slack.png" (503)
$1 @ window.dart:120
/assets/flutterLogo.png:1 Failed to load resource: the server responded with a status of 503 ()
window.dart:120 Error while trying to load an asset: Failed to load asset at "assets/flutterLogo.png" (503)
$1 @ window.dart:120
/assets/kross.jpg:1 Failed to load resource: the server responded with a status of 503 ()
window.dart:120 Error while trying to load an asset: Failed to load asset at "assets/kross.jpg" (503)
$1 @ window.dart:120
/assets/codingRocket2.png:1 Failed to load resource: the server responded
最佳答案
您应该将照片添加到 pubspec.yaml 文件并将您的 Assets 文件夹上传到 Web 服务器。可能是关于不上传文件夹
关于Flutter Web Assets 图像在部署到 Web 服务器时不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58878346/