我有一个 Flutter Web 应用程序,它在本地运行良好,但在使用部署后
firebase deploy
Run Code Online (Sandbox Code Playgroud)
图像未显示在网站上,我检查了资产是否已通过跟踪上传,例如 my_app.firebaseapp.com/assets/assets/card.jpg。(并且图像在那里,所以它已经正确上传,但由于某种原因它没有显示在主页本身上)。
网址:https : //websitehostingtry.web.app/#/
https://websitehostingtry.web.app/assets/images/card.jpg
在本地运行相同时:
flutter run -d chrome --release
Run Code Online (Sandbox Code Playgroud)
我的 Pubspec.yaml 文件:
name: website_try
description: A new Flutter project.
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.3
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
assets:
- images/
Run Code Online (Sandbox Code Playgroud)
在我的飞镖代码中,我只是更改了默认代码以在计数器之后添加图像...
Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
Expanded(
child: Image.network('assets/images/card.jpg'),
)
],
), …
Run Code Online (Sandbox Code Playgroud) 我创建了一个flutter web
使用网络图像和资产图像的项目,在我的电脑上调试时一切正常,但是当我将其部署到 Web 服务器时,网络图像工作正常,但资产图像根本不显示。当我在 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: …
Run Code Online (Sandbox Code Playgroud)