当我使用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。
或者可以将图像定义为颤振资产和图标以某种方式生成?
当前回答
遵循以下步骤:-
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
其他回答
遵循以下步骤:-
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
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应用程序添加自适应启动器图标
我按照以下步骤进行了修改:
1)请在您的pubspec中添加此依赖项。yaml页面
dev_dependencies:
flutter_test:
sdk: flutter
flutter_launcher_icons: ^0.7.4
2)你必须在你的项目上上传一个你想要作为启动器图标的图像/图标。(我已经在我的项目中创建了一个文件夹名称:image,然后在image文件夹中上传logo.png)。现在您必须添加以下代码并将图像路径粘贴到pubspec中的image_path:上。yaml的页面。
flutter_icons:
image_path: "images/logo.png"
android: true
ios: true
3)进入终端执行如下命令:
flutter pub get
4)执行命令后输入以下命令:
flutter pub run flutter_launcher_icons:main
5)完成
注意:(当然从。添加一个更新的依赖项。
https://pub.dev/packages/flutter_launcher_icons#-installing-tab-
)
最好的方法是分别改变iOS和Android的启动器图标。
分别修改iOS和Android模块的图标。 该插件从相同的图标产生不同大小的图标,这些图标是扭曲的。
点击这个链接: https://flutter.dev/docs/deployment/android
我建议你使用下面链接的这个网站
应用图标创造者
步骤1:上传图片
步骤2:做必要的修改,然后点击下载(不要更改文件名)
步骤3:解压下载的Zip文件在相应的文件夹
android/app/src/main/res