当我使用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图标文件替换为您自己的图像。这个网站将帮助你把你的png转换成各种大小的启动器图标:
https://romannurik.github.io/AndroidAssetStudio/icons-launcher.html
其他回答
最好的方法是分别改变iOS和Android的启动器图标。
分别修改iOS和Android模块的图标。 该插件从相同的图标产生不同大小的图标,这些图标是扭曲的。
点击这个链接: https://flutter.dev/docs/deployment/android
遵循简单的步骤:
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的游戏风格。
我建议你使用下面链接的这个网站
应用图标创造者
步骤1:上传图片
步骤2:做必要的修改,然后点击下载(不要更改文件名)
步骤3:解压下载的Zip文件在相应的文件夹
android/app/src/main/res
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
遵循以下步骤:-
1. 在pubspec中添加flutter_luncher_icons的依赖项。yaml文件。你可以在这里找到这个插件。
2. 在资产文件夹和pubspec中添加所需的图像。Yaml文件如下。
pubspec.yaml
name: NewsApi.org
description: A new Flutter application.
# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.1
fluttertoast: ^7.1.6
toast: ^0.1.5
flutter_launcher_icons: ^0.8.0
dev_dependencies:
flutter_test:
sdk: flutter
flutter_icons:
image_path: "assets/icon/newsicon.png"
android: true
ios: false
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
assets:
- assets/images/dropbox.png
fonts:
- family: LangerReguler
fonts:
- asset: assets/langer_reguler.ttf
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
3.执行terminal flutter pub get命令,然后执行flutter_luncher_icon命令。这是成功运行命令后得到的结果。并成功生成了午餐图标。
我的终端
[E:\AndroidStudioProjects\FlutterProject\NewsFlutter\news_flutter>flutter pub get
Running "flutter pub get" in news_flutter... 881ms
E:\AndroidStudioProjects\FlutterProject\NewsFlutter\news_flutter>flutter pub run flutter_launcher_icons:main
════════════════════════════════════════════
FLUTTER LAUNCHER ICONS (v0.8.0)
════════════════════════════════════════════
• Creating default icons Android
• Overwriting the default Android launcher icon with a new icon
✓ Successfully generated launcher icons