当我使用flutter create命令创建应用程序时,flutter标志将用作两个平台的应用程序图标。

如果我想改变应用程序的图标,我是否应该去两个平台的目录并替换那里的图像?我说的平台目录是myapp/ios/Runner/Assets.xcassets/AppIcon。apppiconset用于iOS, myapp/android/app/src/main/res用于android。

或者可以将图像定义为颤振资产和图标以某种方式生成?


当前回答

最好的方法是分别改变iOS和Android的启动器图标。

分别修改iOS和Android模块的图标。 该插件从相同的图标产生不同大小的图标,这些图标是扭曲的。

点击这个链接: https://flutter.dev/docs/deployment/android

其他回答

我使用很少的方法来更换颤振应用程序lancher图标,但只有手动方法是有点容易和好。因为你会知道它是如何运作的。

更改flutter ios图标。首先得到你的图标1024×1024像素的副本,并生成一组图标的android和ios使用appicon。有限公司发电机。 当你得到压缩文件,它工作创建两个文件夹ios和android打开ios文件夹和复制文件夹,并替换一个在你的ios/runner目录。

对于android,复制android文件夹中的所有文件夹,并替换在android/app/src/main/res/drawable中的文件夹。

在ios和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。

您必须将Flutter图标文件替换为您自己的图像。这个网站将帮助你把你的png转换成各种大小的启动器图标:

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

试试IconKitchen吧,它是Android Asset Studio的继承者,是为Android、iOS和网页制作高度自定义应用图标的绝佳新方法。

遵循以下步骤:-

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