简体   繁体   English

如何更改 Flutter 上的应用程序启动器图标?

[英]How to change the application launcher icon on Flutter?

When I create an app with a flutter create command, the flutter logo is used as an application icon for both platforms.当我使用flutter create命令创建应用程序时,flutter 徽标用作两个平台的应用程序图标。

If I want to change the app icon, shall I go to both platforms directories and replace images there?, by platforms directories I mean myapp/ios/Runner/Assets.xcassets/AppIcon.appiconset for iOS and myapp/android/app/src/main/res for Android.如果我想更改应用程序图标,我应该 go 到两个平台目录并替换那里的图像吗?平台目录我的意思是myapp/ios/Runner/Assets.xcassets/AppIcon.appiconset for iOS 和myapp/android/app/src/main/res为 Android。

Or is it possible to define an image as a Flutter Asset and the icons are generated somehow?.或者是否可以将图像定义为Flutter Asset并以某种方式生成图标?

Flutter Launcher Icons has been designed to help quickly generate launcher icons for both Android and iOS: https://pub.dartlang.org/packages/flutter_launcher_icons Flutter Launcher Icons 旨在帮助快速生成适用于 Android 和 iOS 的启动器图标: https ://pub.dartlang.org/packages/flutter_launcher_icons

  • Add the package to your pubspec.yaml file (within your Flutter project) to use it将包添加到您的 pubspec.yaml 文件(在您的 Flutter 项目中)以使用它
  • Within pubspec.yaml file specify the path of the icon you wish to use for the app and then choose whether you want to use the icon for the iOS app, Android app or both.在 pubspec.yaml 文件中指定您希望用于应用程序的图标的路径,然后选择是否要将图标用于 iOS 应用程序、Android 应用程序或两者。
  • Run the package运行包
  • Voila!瞧! The default launcher icons have now been replaced with your custom icon默认启动器图标现已替换为您的自定义图标

I'm hoping to add a video to the GitHub README to demonstrate it我希望在 GitHub README 中添加一个视频来演示它

Video showing how to run the tool can be found here .可以在此处找到显示如何运行该工具的视频。

If anyone wants to suggest improvements / report bugs, please add it as an issue on the GitHub project .如果有人想提出改进建议/报告错误,请将其作为问题添加到 GitHub 项目中。

Update: As of Wednesday 24th January 2018, you should be able to create new icons without overriding the old existing launcher icons in your Flutter project.更新:截至 2018 年 1 月 24 日星期三,您应该能够在不覆盖 Flutter 项目中旧的现有启动器图标的情况下创建新图标。

Update 2: As of v0.4.0 (8th June 2018) you can specify one image for your Android icon and a separate image for your iOS icon.更新 2:从 v0.4.0(2018 年 6 月 8 日)开始,您可以为您的 Android 图标指定一个图像,为您的 iOS 图标指定一个单独的图像。

Update 3: As of v0.5.2 (20th June 2018) you can now add adaptive launcher icons for the Android app of your Flutter project更新 3:从 v0.5.2(2018 年 6 月 20 日)开始,您现在可以为 Flutter 项目的 Android 应用添加自适应启动器图标

Setting the launcher icons like a native developer像原生开发者一样设置启动器图标

I was having some trouble using and understanding the flutter_launcher_icons package.我在使用和理解flutter_launcher_icons包时遇到了一些麻烦。 This answer is how you would do it if you were creating an app for Android or iOS natively.如果您在本地创建适用于 Android 或 iOS 的应用程序,那么这个答案就是您将如何做到的。 It is pretty fast and easy once you have done it a few times.一旦你完成了几次,它就非常快速和容易。

Android安卓

Android launcher icons have both a foreground and a background layer. Android 启动器图标同时具有前景层和背景层。

在此处输入图像描述

(image adapted from Android documentation ) (图片改编自Android 文档

The easiest way to create launcher icons for Android is to use the Asset Studio that is available right in Android Studio.为 Android 创建启动器图标的最简单方法是使用 Android Studio 中提供的 Asset Studio。 You don't even have to leave your Flutter project.你甚至不必离开你的 Flutter 项目。 (VS Code users, you might consider using Android Studio just for this step. It's really very convenient and it doesn't hurt to be familiar with another IDE.) (VS Code 的用户,你可以考虑使用 Android Studio 只是为了这一步。真的很方便,熟悉另一个 IDE 也没有什么坏处。)

Right click on the android folder in the project outline.右键单击项目大纲中的android文件夹。 Go to New > Image Asset .转到新建 > 图像资产 (Try right clicking the android/app folder if you don't see Image Asset as an option. Also see the comments below for more suggestions.) Now you can select an image to create your launcher icon from. (如果您没有看到图像资源选项,请尝试右键单击android/app文件夹。另请参阅下面的评论以获取更多建议。)现在您可以选择一个图像来创建您的启动器图标。

Note: I usually use a 1024x1024 pixel image but you should certainly use nothing smaller that 512x512 .注意:我通常使用1024x1024像素的图像,但您当然应该使用小于512x512的图像。 If you are using Gimp or Inkscape, you should have two layers, one for the foreground and one for the background.如果您使用 Gimp 或 Inkscape,您应该有两层,一层用于前景,一层用于背景。 The foreground image should have transparent areas for the background layer to show through.前景图像应具有透明区域以供背景层显示。

在此处输入图像描述

(lion clipart from here ) (来自这里的狮子剪贴画)

This will replace the current launcher icons.这将替换当前的启动器图标。 You can find the generated icons in the mipmap folders:您可以在mipmap文件夹中找到生成的图标:

If you would prefer to create the launcher icons manually, see this answer for help.如果您希望手动创建启动器图标,请参阅此答案以获取帮助。

Finally, make sure that the launcher icon name in the AndroidManifest is the same as what you called it above ( ic_launcher by default):最后,确保 AndroidManifest 中的启动器图标名称与您在上面调用的名称相同(默认为ic_launcher ):

application android:icon="@mipmap/ic_launcher"

Run the app in the emulator to confirm that the launcher icon was created successfully.在模拟器中运行应用程序以确认启动器图标已成功创建。

iOS iOS

I always used to individually resize my iOS icons by hand, but if you have a Mac, there is a free app in the Mac App Store called Icon Set Creator .我过去常常手动单独调整我的 iOS 图标大小,但如果你有一台 Mac,Mac App Store 中有一个名为Icon Set Creator的免费应用程序。 You give it an image (of at least 1024x1024 pixels) and it will spit out all the sizes that you need (plus the Contents.json file).你给它一个图像(至少1024x1024像素),它会吐出你需要的所有尺寸(加上Contents.json文件)。 Thanks to this answer for the suggestion.感谢这个答案的建议。

iOS icons should not have any transparency. iOS 图标不应该有任何透明度。 See more guidelines here . 在此处查看更多指南。

After you have created the icon set, start Xcode (assuming you have a Mac) and use it to open the ios folder in your Flutter project.创建图标集后,启动 Xcode(假设您有 Mac)并使用它打开 Flutter 项目中的ios文件夹。 Then go to Runner > Assets.xcassets and delete the AppIcon item.然后转到Runner > Assets.xcassets并删除 AppIcon 项。

在此处输入图像描述

After that right-click and choose Import... .之后右键单击并选择Import... Choose the icon set that you just created.选择您刚刚创建的图标集。

That's it.而已。 Confirm that the icon was created by running the app in the simulator.确认图标是通过在模拟器中运行应用程序创建的。

If you don't have a Mac...如果你没有Mac...

You can still create all of the images by hand.您仍然可以手动创建所有图像。 In your Flutter project go to ios/Runner/Assets.xcassets/AppIcon.appiconset .在您的 Flutter 项目中,转到ios/Runner/Assets.xcassets/AppIcon.appiconset

The image sizes that you need are the multiplied sizes in the filename.您需要的图像大小是文件名中的乘积大小。 For example, Icon-App-29x29@3x.png would be 29 times 3 , that is, 87 pixels square.例如, Icon-App-29x29@3x.png将是29乘以3 ,即87像素正方形。 You either need to keep the same icon names or edit the JSON file.您需要保持相同的图标名称或编辑 JSON 文件。

Follow simple steps:遵循简单的步骤:

1. Add flutter_launcher_icons Plugin to pubspec.yaml 1.pubspec.yaml中添加flutter_launcher_icons插件

eg例如

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. Prepare an app icon for the specified path. 2.为指定路径准备一个应用图标。 eg icon/icon.png

3. Execute command on the terminal to Create app icons: 3.在终端执行命令创建应用图标:

$ flutter pub get

$ flutter pub run flutter_launcher_icons:main

To check check all available options and to set different icons for android and iOS please refer this要检查所有可用选项并为 android 和 iOS 设置不同的图标,请参阅

Update:更新:

flutter_launcher_icons 0.8.0 Version (12th Sept 2020) has Added flavours support flutter_launcher_icons 0.8.0版本(2020 年 9 月 12 日)增加了风味支持

Flavors are typically used to build your app for different environments such as dev and prod Flavors 通常用于为不同的环境(例如devprod )构建您的应用程序

The community has written some articles and packages you might find useful.社区已经写了一些你可能会觉得有用的文章和包。 These articles address flavors for both iOS and Android.这些文章介绍了 iOS 和 Android 的风格。

I have changed it in the following steps:我已按以下步骤对其进行了更改:

1) please add this dependency on your pubspec.yaml page 1)请在您的 pubspec.yaml 页面上添加此依赖项

 dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_launcher_icons: ^0.7.4

2) you have to upload an image/icon on your project which you want to see as a launcher icon. 2)您必须在您的项目上上传一个图像/图标,您希望将其视为启动器图标。 (i have created a folder name:image in my project then upload the logo.png in the image folder). (我在我的项目中创建了一个文件夹名称:图像,然后将 logo.png 上传到图像文件夹中)。 Now you have to add the below codes and paste your image path on image_path: in pubspec.yaml page.现在您必须添加以下代码并将图像路径粘贴到 image_path: 的 pubspec.yaml 页面中。

flutter_icons:
  image_path: "images/logo.png"
  android: true
  ios: true

3) Go to terminal and execute this command: 3)转到终端并执行此命令:

flutter pub get

4) After executing the command then enter below command: 4)执行命令后输入以下命令:

flutter pub run flutter_launcher_icons:main

5) Done 5) 完成

NB: (of course add an updated dependency from注意:(当然添加更新的依赖项

https://pub.dev/packages/flutter_launcher_icons#-installing-tab- https://pub.dev/packages/flutter_launcher_icons#-installing-tab-

) )

You have to replace the Flutter icon files with images of your own.您必须将 Flutter 图标文件替换为您自己的图像。 This site will help you turn your png into launcher icons of various sizes:该站点将帮助您将 png 转换为各种大小的启动器图标:

https://romannurik.github.io/AndroidAssetStudio/icons-launcher.html https://romanurik.github.io/AndroidAssetStudio/icons-launcher.html

I would suggest You to use this website Linked Below我建议你使用下面链接的这个网站

App Icon Creator 应用图标创建者

Step-1: upload The Image,第 1 步:上传图片,

Step-2: Make necessary Changes And Click on download(dont change the file name)第2步:进行必要的更改并单击下载(不要更改文件名)

Step-3: Extract the Downloaded Zip File In the respective folder第 3 步:在相应文件夹中提取下载的 Zip 文件

android/app/src/main/res

Best & Recommended way to set App Icon in Flutter.在 Flutter 中设置 App Icon 的最佳推荐方式。

I found one plugin to set app icon in flutter named flutter_launcher_icons .我找到了一个名为flutter_launcher_icons的插件来在颤振中设置应用程序图标。 We can use this plugin to set the app icon in flutter.我们可以使用这个插件在flutter中设置应用程序图标。

  1. Add this plugin in pubspec.yaml file in project root directory.在项目根目录的 pubspec.yaml 文件中添加这个插件。 Please check below code,请检查以下代码,
dependencies:    
 flutter:    
  sdk: flutter    
 cupertino_icons: ^0.1.2    
 flutter_launcher_icons: ^0.7.2+1**    

Save the file and run flutter pub get on terminal.保存文件并在终端上运行 flutter pub get。

  1. Create a folder assets in the root of the project in folder assets also create a folder icon and place your app icon inside this folder.在文件夹 assets 中项目的根目录中创建文件夹 assets 还创建一个文件夹图标并将您的应用程序图标放置在此文件夹中。 I will recommend to user 1024x1024 app icon size.我会向用户推荐 1024x1024 的应用程序图标大小。 I have placed app icon inside icon folder and now I have app icon path as assets/icon/icon.png我已将应用程序图标放在图标文件夹中,现在我将应用程序图标路径设置为 assets/icon/icon.png

  2. Now, in pubspec.yaml add the below code,现在,在 pubspec.yaml 添加以下代码,

flutter_icons:    
 android: "launcher_icon"    
 ios: true    
 image_path: "assets/icon/icon.png"
  1. Save the file and run flutter pub get on terminal.保存文件并在终端上运行 flutter pub get。 After running command run second command as below运行命令后运行第二个命令如下
flutter pub run flutter_launcher_icons:main -f pubspec.yaml 

Then Run App然后运行应用程序

Flutter has its own default icon for every app in its Android and Ios folder so there are few steps that I would like to show to change the app icon. Flutter 在其 Android 和 Ios 文件夹中的每个应用程序都有自己的默认图标,因此我想展示几个步骤来更改应用程序图标。

  1. Head over to https://appicon.co/ and generate your own icon using icon image (the zip file contains two main folders android and Assets.xcassets )前往https://appicon.co/并使用图标图像生成您自己的图标(zip 文件包含两个主要文件夹androidAssets.xcassets
  2. For android: Go inside android\app\src\main\res in your flutter app and there paste the android folder content.对于 android:进入 Flutter 应用程序中的android\app\src\main\res并粘贴 android 文件夹内容。
  3. For IOS: Go inside ios\Runner in your flutter app and there paste the Assets.xcassets content对于 IOS:进入 Flutter 应用程序中的ios\Runner并粘贴 Assets.xcassets 内容
  4. Restart your emulator or rebuild your application 😁重启你的模拟器或重建你的应用程序😁

Best way is to change launcher icons separately for both iOS and Android.最好的方法是分别为 iOS 和 Android 更改启动器图标。

Change the icons in iOS and Android module separately.分别更改 iOS 和 Android 模块中的图标。 The plugin produces different size icons from the same icon which are distorted.该插件从扭曲的相同图标生成不同大小的图标。

Follow this link: https://flutter.dev/docs/deployment/android按照这个链接: https ://flutter.dev/docs/deployment/android

I have always changed the icon in the directories you mentioned. 我一直在更改您提到的目录中的图标。 I'm not aware of any mechanism to let flutter generate icons for you. 我不知道有什么机制可以让flutter为您生成图标。

Follow these steps:-按着这些次序:-

1. Add dependencies of flutter_luncher_icons in pubspec.yaml file.You can find this plugin from here . 1.pubspec.yaml文件中添加flutter_luncher_icons的依赖。你可以从这里找到这个插件。

2. Add your required images in asstes folder and pubspec.yaml file as below . 2.asstes 文件夹pubspec.yaml文件中添加所需的图像,如下所示。

pubspec.yaml发布规范.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. Then run the command in terminal flutter pub get and then flutter_luncher_icon .This is what I get the result after the successfully run the command . 3.然后在终端flutter pub get中运行命令,然后flutter_luncher_icon 。这是我成功运行命令后得到的结果。 And luncher icon is also generated successfully.午餐图标也生成成功。

My Terminal我的终端

[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
  • You can use flutter_launcher_icons 0.9.0 by this link您可以通过此链接使用flutter_launcher_icons 0.9.0
  • If you need the demo of how to change the icon launcher in flutter check this out如果您需要有关如何在颤振中更改图标启动器的演示,请查看此

I hope my answer can help you brother.希望我的回答能帮到你兄弟。 comment below if you have any questions.如果您有任何问题,请在下方评论。 Good luck brother.祝兄弟好运。

The one marked as correct answer, is not enough, you need one more step, type this command in the terminal in order to create the icons:标记为正确答案的一个还不够,您还需要一步,在终端中键入此命令以创建图标:

flutter pub run flutter_launcher_icons:main颤振酒吧运行颤振启动器图标:主要

I use few methods for chaging flutter app lancher icon but only the manuall method is a bit easy and good.我使用很少的方法来更改 Flutter 应用程序 lancher 图标,但只有手动方法有点简单和好。 Because you will know how it work.因为你会知道它是如何工作的。

So to change flutter ios icon.所以要改变颤动的ios图标。 First get copy of your icon 1024×1024 pixel and generate set of icons for android and ios using appicon.co generator.首先获取您的图标 1024×1024 像素的副本,并使用 appicon.co 生成器为 android 和 ios 生成一组图标。 When you get zip file it work contact two folder ios and android open ios folder and copy folder and replace the one in your ios/runner directory.当您获得 zip 文件时,它可以联系两个文件夹 ios 和 android 打开 ios 文件夹并复制文件夹并替换您的 ios/runner 目录中的一个。

For android copy all folder present in android folder and replace the ones present in the android/app/src/main/res/drawable here.对于 android,复制 android 文件夹中的所有文件夹,并在此处替换 android/app/src/main/res/drawable 中的文件夹。

After replacing folder on both ios and android stop the app and re run and your icons will be changed.在 ios 和 android 上替换文件夹后,停止应用程序并重新运行,您的图标将被更改。

When a new Flutter app is created, it has a default launcher icon.创建新的 Flutter 应用程序时,它有一个默认的启动器图标。 To customize this icon, you might want to check out the flutter_launcher_icons package.要自定义此图标,您可能需要查看flutter_launcher_icons包。

Alternatively, you can do it manually using the following steps.或者,您可以使用以下步骤手动执行此操作。 This step covers replacing these placeholder icons with your app's icons:此步骤包括用您的应用程序图标替换这些占位符图标:

Android安卓

  1. Review the Material Design product icons guidelines for icon design.查看用于图标设计的Material Design 产品图标指南。

  2. In the <app dir>/android/app/src/main/res/ directory, place your icon files in folders named using configuration qualifiers.<app dir>/android/app/src/main/res/目录中,将您的图标文件放在使用配置限定符命名的文件夹中。 The default mipmap- folders demonstrate the correct naming convention.默认的mipmap-文件夹展示了正确的命名约定。

  3. In AndroidManifest.xml , update the application tag's android:icon attribute to reference icons from the previous step (for example, <application android:icon="@mipmap/ic_launcher" .. .).AndroidManifest.xml ,更新应用程序标签的android:icon属性以引用上一步中的图标(例如, <application android:icon="@mipmap/ic_launcher" .. .)。

  4. To verify that the icon has been replaced, run your app and inspect the app icon in the Launcher.要验证图标是否已被替换,请运行您的应用程序并检查启动器中的应用程序图标。

iOS IOS

  1. Review the iOS App Icon guidelines.查看iOS 应用图标指南。
  2. In the Xcode project navigator, select Assets.xcassets in the Runner folder.在 Xcode 项目导航器中,选择Runner文件夹中的Assets.xcassets Update the placeholder icons with your own app icons.使用您自己的应用程序图标更新占位符图标。
  3. Verify the icon has been replaced by running your app using a flutter run .通过使用flutter run运行您的应用程序来验证图标是否已被替换。

试试IconKitchen ,它是 Android Asset Studio 的继承者,它是一种为 Android、iOS 和 Web 制作高度可定制的应用程序图标的绝佳新方法。

I have changed it in the following steps: 我已按照以下步骤进行了更改: 在此处输入图片说明

最简单的方法是使用flutter_launcher_icons包但不能完美运行所以我更喜欢使用这个网站应用程序图标来制作android和ios的应用程序图标然后你只需要替换android/app/src/main下ANDROID的mipmap文件夹/res/ios/Runner/下IOS的Assets.xcassets

The flutter_launcher_icons package recommended in many answers above hasn't been updated for quite some time now and is throwing an uncaught exception.上面许多答案中推荐的 flutter_launcher_icons 包已经有一段时间没有更新了,并且正在抛出一个未捕获的异常。

You can use the package icons_launcher instead though.不过,您可以使用包icons_launcher

  1. Update the pubspec.yaml更新 pubspec.yaml
dev_dependencies:
  icons_launcher: ^1.1.7

flutter_icons:
  image_path: 'assets/ic_logo_border.png'
  ios: true
  android: true
  1. Run the package运行包
flutter pub get
flutter pub run icons_launcher:main

flutter_launcher_icons: ^0.10.0 flutter_launcher_icons: ^0.10.0

Add this in your pubspec.yaml file将此添加到您的pubspec.yaml文件中

dev_dependencies:
  flutter_launcher_icons: "^0.10.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

after adding this run the below command添加后运行以下command

$ flutter pub get

$ flutter pub run flutter_launcher_icons:main

You can follow this site from medium if you want to set images as your flutter application launcher如果你想将图像设置为你的 flutter 应用程序启动器,你可以从媒体关注这个站点

https://medium.com/@psyanite/how-to-add-app-launcher-icons-in-flutter-bd92b0e0873a https://medium.com/@psyanite/how-to-add-app-launcher-icons-in-flutter-bd92b0e0873a

Without any packages没有任何包裹

Android安卓

  1. Create an adaptive launcher icon in your Flutter project's root directory using the Android Asset Studio.使用Android Asset Studio 在 Flutter 项目的根目录中创建自适应启动器图标。

  2. Add the generated launcher icon files to the project's android/app/src/main/res/mipmap-*/ directories.将生成的启动器图标文件添加到项目的android/app/src/main/res/mipmap-*/目录。

  3. Edit the android/app/src/main/AndroidManifest.xml file and add the following line below the tag:编辑android/app/src/main/AndroidManifest.xml文件并在标签下方添加以下行:

<application android:icon="@mipmap/ic_launcher">

  1. Run the flutter build apk command to generate an APK with the new launcher icon.运行flutter build apk命令以生成带有新启动器图标的 APK。

iOS iOS

  1. Create an Adaptive App Icon in your Flutter project's root directory using the App Icon Generator .使用App Icon Generator在 Flutter 项目的根目录中创建自适应应用程序图标。

  2. Add the generated app icon files to the project's ios/Runner/Assets.xcassets/AppIcon.appiconset/ directory.将生成的app图标文件添加到项目的ios/Runner/Assets.xcassets/AppIcon.appiconset/目录下。

  3. Edit the ios/Runner/Info.plist file and add the following line below the tag:编辑ios/Runner/Info.plist文件并在标签下方添加以下行:

<key>CFBundleIconName</key>
<string>AppIcon</string>
  1. Run the flutter build ios command to generate an IPA with the new launcher icon.运行 flutter build ios 命令以生成带有新启动器图标的 IPA。

Easy way to change app icon go to android/app/src/main/res and paste your image to all directory contains mipmap and run更改应用程序图标的简单方法转到 android/app/src/main/res 并将图像粘贴到包含 mipmap 的所有目录并运行

The best way is to get the image you want to make as launcher icon and then go to this site https://www.appicon.co/ .最好的方法是获取您想要制作的启动器图标图像,然后 go 到此站点https://www.appicon.co/ drop the image here.把图片放在这里。 and choose all platforms you want to make launcher icon for.并选择您要为其制作启动器图标的所有平台。 After that you will receive a zip file and in it all the launcher icons will be there.之后您将收到一个 zip 文件,其中包含所有启动器图标。 there you will see all the launcher icons with different sizes.在那里你会看到所有不同大小的启动器图标。 just replace them with the existing ones and in android manifest file change the name to whatever the name of the launcher icons is.只需将它们替换为现有的,然后在 android 清单文件中将名称更改为启动器图标的任何名称。 and restart the app you will see the launcher icon changed.并重新启动应用程序,您将看到启动器图标已更改。

you can achieve this by using flutter_launcher_icons in pubspec.yaml您可以通过在 pubspec.yaml 中使用 flutter_launcher_icons 来实现此目的

another way is to use one for android and another one for iOS另一种方法是将一个用于 android,另一个用于 iOS

**There are Two ways to change the App Icon: **有两种方法可以更改应用程序图标:

  1. Manually changing the files of Icon in Both Android and IOS folder by uploading all the required sizes of the icon.通过上传所有需要的图标大小,手动更改 Android 和 IOS 文件夹中的图标文件。
  2. Using Package which will add all the sizes of Icons in Android and IOS folders Automatically.**使用 Package 将自动添加 Android 和 IOS 文件夹中所有大小的图标。**

****Details:**** https://www.geeksforgeeks.org/flutter-changing-app-icon/ ****详情:**** https://www.geeksforgeeks.org/flutter-changed-app-icon/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM