当我使用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。
或者可以将图像定义为颤振资产和图标以某种方式生成?
当前回答
没有任何包装
安卓
使用Android Asset Studio在Flutter项目的根目录中创建一个自适应启动器图标。 将生成的启动器图标文件添加到项目的android/app/src/main/res/mipmap-*/目录下。 编辑android/app/src/main/AndroidManifest.xml文件,并在标签下面添加如下一行:
<应用android:图标= " @mipmap / ic_launcher”>
运行flutter build apk命令生成带有新启动器图标的apk。
iOS
使用应用程序图标生成器在Flutter项目的根目录中创建自适应应用程序图标。 将生成的应用图标文件添加到项目的ios/Runner/Assets.xcassets/AppIcon。appiconset /目录中。 编辑ios/Runner/Info. conf文件。Plist文件,并在标签下面添加以下一行:
<key>CFBundleIconName</key>
<string>AppIcon</string>
运行flutter build ios命令生成带有新启动器图标的IPA。
其他回答
遵循简单的步骤:
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已设计用于帮助快速生成Android和iOS的启动器图标:https://pub.dartlang.org/packages/flutter_launcher_icons
将包添加到您的pubspec中。yaml文件(在Flutter项目中)来使用它 pubspec之内。yaml文件指定图标的路径,你希望使用的应用程序,然后选择是否要使用图标的iOS应用程序,Android应用程序或两者。 运行包 瞧!默认的启动器图标现在已经替换为您的自定义图标
我希望在GitHub README中添加一个视频来演示它
演示如何运行该工具的视频可以在这里找到。
如果有人想提出改进建议/报告错误,请将其作为一个问题添加到GitHub项目中。
更新:截至2018年1月24日星期三,您应该能够创建新的图标,而不覆盖颤振项目中旧的现有启动器图标。
更新2:从v0.4.0(2018年6月8日)开始,你可以为Android图标指定一个图像,为iOS图标指定一个单独的图像。
更新3:截至v0.5.2(2018年6月20日),您现在可以为您的Flutter项目的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
最好的方法是分别改变iOS和Android的启动器图标。
分别修改iOS和Android模块的图标。 该插件从相同的图标产生不同大小的图标,这些图标是扭曲的。
点击这个链接: https://flutter.dev/docs/deployment/android
遵循以下步骤:-
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