找不到波动资产图像 [英] Flutter assets image not find
本文介绍了找不到波动资产图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用Visual Studio代码和Andriod Studio IDE以及其他AVD管理器,但是当我使用图片"资产运行应用程序时出现错误,没有找到资产的文件或变体:assets/puffin.jpeg.
I use Visual studio code and Andriod studio IDE and different AVD managers but when I run app with Image asset get an error No file or variants found for asset: assets/puffin.jpeg.
简单的例子:main.dart
Simple example: main.dart
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
var title = 'Web Images';
return MaterialApp(
title: title,
home: Scaffold(
appBar: AppBar(
title: Text(title),
),
body: Container(
alignment: Alignment.center,
child: Image.asset(
"assets/puffin.jpeg",
width: 280.0,
),
)
),
);
}
}
pubspec.yaml
pubspec.yaml
name: flutter_app_test
description: A new Flutter application.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
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:
- assets/puffin.jpeg
扑扑医生
[√] Flutter (Channel stable, v1.17.5, on Microsoft Windows [Version 10.0.18363.959], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
[√] Android Studio (version 4.0)
[√] VS Code (version 1.47.3)
[√] Connected device (1 available)
• No issues found!
推荐答案
我修复了一个错误,删除了文件夹 .dart_tool 并重新运行应用程序,但错误消失了.
I fix an error I delete folder .dart_tool and rerun app and error gone.
这篇关于找不到波动资产图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文