当我使用flutter create命令创建应用程序时,flutter标志将用作两个平台的应用程序图标。
如果我想改变应用程序的图标,我是否应该去两个平台的目录并替换那里的图像?我说的平台目录是myapp/ios/Runner/Assets.xcassets/AppIcon。apppiconset用于iOS, myapp/android/app/src/main/res用于android。
或者可以将图像定义为颤振资产和图标以某种方式生成?
当我使用flutter create命令创建应用程序时,flutter标志将用作两个平台的应用程序图标。
如果我想改变应用程序的图标,我是否应该去两个平台的目录并替换那里的图像?我说的平台目录是myapp/ios/Runner/Assets.xcassets/AppIcon。apppiconset用于iOS, myapp/android/app/src/main/res用于android。
或者可以将图像定义为颤振资产和图标以某种方式生成?
当前回答
flutter_launcher_icons: ^ 0.11.0
将此添加到你的pubspec中。yaml文件
dev_dependencies:
flutter_launcher_icons: "^0.11.0"
flutter_icons:
android: "launcher_icon"
ios: true
image_path: "assets/icon/icon.png"
min_sdk_android: 21 # android min sdk min:16, default 21
# optionally, as transparency is not allowed on app store
# remove_alpha_ios: true
添加后,运行以下命令
$颤振酒吧得到
$ flutter pub运行flutter_launcher_icons:main
其他回答
flutter_launcher_icons: ^ 0.11.0
将此添加到你的pubspec中。yaml文件
dev_dependencies:
flutter_launcher_icons: "^0.11.0"
flutter_icons:
android: "launcher_icon"
ios: true
image_path: "assets/icon/icon.png"
min_sdk_android: 21 # android min sdk min:16, default 21
# optionally, as transparency is not allowed on app store
# remove_alpha_ios: true
添加后,运行以下命令
$颤振酒吧得到
$ flutter pub运行flutter_launcher_icons:main
在Flutter中设置应用程序图标的最佳推荐方法。
我找到了一个插件来设置应用程序图标在flutter名为flutter_launcher_icons。我们可以使用这个插件在flutter中设置应用程序图标。
在pubspec中添加此插件。项目根目录下的Yaml文件。请检查以下代码,
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
flutter_launcher_icons: ^0.7.2+1**
保存文件并在终端上运行flutter pub get。
在项目的根文件夹资产中创建一个文件夹资产,同时创建一个文件夹图标,并将应用程序图标放在这个文件夹中。我将推荐给用户1024x1024的应用程序图标大小。我已经把应用程序图标放在图标文件夹内,现在我有应用程序图标路径为assets/icon/icon.png 现在,在pubspec中。Yaml添加下面的代码,
flutter_icons:
android: "launcher_icon"
ios: true
image_path: "assets/icon/icon.png"
保存文件并在终端上运行flutter pub get。运行命令后,运行第二条命令,如下所示
flutter pub run flutter_launcher_icons:main -f pubspec.yaml
然后运行App
遵循简单的步骤:
1. 添加flutter_launcher_icons Plugin到pubspec.yaml
e.g.
dev_dependencies:
flutter_test:
sdk: flutter
flutter_launcher_icons: "^0.9.0"
flutter_icons:
image_path: "icon/icon.png"
android: true
ios: true
# optionally, as transparency is not allowed on app store
# remove_alpha_ios: true
2. 为指定的路径准备一个应用程序图标。 例如图标/程序
3.在终端执行命令创建应用图标:
$颤振酒吧得到
$ flutter pub运行flutter_launcher_icons:main
要检查所有可用的选项,并设置不同的图标安卓和iOS,请参考此
更新:
flutter_launcher_icons 0.8.0版本(2020年9月12日)增加了口味支持
flavor通常用于为不同的环境(如dev和prod)构建应用程序
社区写了一些文章和软件包,您可能会觉得有用。这两篇文章分别阐述了iOS和Android的游戏风格。
上面许多答案中推荐的flutter_launcher_icons包现在已经有一段时间没有更新了,并且正在抛出一个未捕获的异常。
你也可以使用icons_launcher包。
更新pubspec.yaml
dev_dependencies:
icons_launcher: ^1.1.7
flutter_icons:
image_path: 'assets/ic_logo_border.png'
ios: true
android: true
运行包
flutter pub get
flutter pub run icons_launcher:main
您必须将Flutter图标文件替换为您自己的图像。这个网站将帮助你把你的png转换成各种大小的启动器图标:
https://romannurik.github.io/AndroidAssetStudio/icons-launcher.html