[英]Failed to precompile flutter_launcher_icons:main:
So I tried using flutter_launcher_icons to automatically change the launcher icon of my simple interest calculator app.所以我尝试使用 flutter_launcher_icons 来自动更改我的简单兴趣计算器应用程序的启动器图标。
This is my code in pubspec.yaml这是我在 pubspec.yaml 中的代码
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.0
flutter_launcher_icons: ^0.8.1
dev_dependencies:
flutter_test:
sdk: flutter
flutter_launcher_icons: "^0.8.0"
flutter_icons:
android: "launcher_icon"
ios: true
image_path: "assets/icon.png"
flutter:
uses-material-design: true
The Error I got after running flutter pub get & flutter pub run flutter_launcher_icons:main运行 flutter pub get & flutter pub run flutter_launcher_icons:main 后出现的错误
Failed to precompile flutter_launcher_icons:main:
/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_launcher_icons-0.8.1/lib/utils.dart:1:8: Error: Error when reading '/C:/src/flutter/flutter/.pub-cache/hosted/
pub.dartlang.org/image-2.1.19/lib/image.dart': The system cannot find the path specified.
import 'package:image/image.dart';
^
/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_launcher_icons-0.8.1/lib/android.dart:4:8: Error: Error when reading '/C:/src/flutter/flutter/.pub-cache/hoste
d/pub.dartlang.org/image-2.1.19/lib/image.dart': The system cannot find the path specified.
import 'package:image/image.dart';
^
/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_launcher_icons-0.8.1/lib/utils.dart:3:1: Error: Type 'Image' not found.
Image createResizedImage(int iconSize, Image image) {
^^^^^
^^^^^
/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_launcher_icons-0.8.1/lib/ios.dart:93:1: Error: Type 'Image' not found.
Image createResizedImage(IosIconTemplate template, Image image) {
^^^^^
pub finished with exit code 1
you can change it like that;你可以这样改变它;
flutter_icons:
android: true
ios: true
image_path: "assets/icon.png"
and no need to use that import 'package:image/image.dart';并且不需要使用那个 import 'package:image/image.dart'; if you take your image from assets no need to import it like that.如果您从资产中获取图像,则无需像那样导入它。 you should create a file named assets and put image in it您应该创建一个名为 assets 的文件并将图像放入其中
after that just paste that in terminal.之后只需将其粘贴到终端中。
flutter pub run flutter_launcher_icons:main
You did not import flutter_launcher_icons
package correctly under dev_dependencies
.您没有在 dev_dependencies 下正确导入flutter_launcher_icons
dev_dependencies
。 You should not use quotes("). You can edit that part with the following one:您不应该使用引号(“)。您可以使用以下内容编辑该部分:
dev_dependencies:
flutter_test:
sdk: flutter
flutter_launcher_icons: ^0.8.0
In my case the image package was not being correctly downloaded, so I went to ~\flutter.pub-cache\hosted\pub.dartlang.org\image-3.0.8 and cloned the rep from git: https://github.com/brendan-duncan/image在我的情况下,图像 package 没有被正确下载,所以我去了 ~\flutter.pub-cache\hosted\pub.dartlang.org\image-3.0.8 并从 git 克隆了代表: Z5E0556C500A187B com/brendan-duncan/图像
After that the command worked.之后,该命令起作用了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.