首页 > 解决方案 > Replacing app launcher icon in flutter with new icon

问题描述

I was looking for changing the app icon of my current app. I cane around the package name flutter_launcher_icons.

I also found I can do by putting an image in mipmap-xxxhdpi in android/app/res folder. And it works.

So my question is why we need additional package(flutter_launcher_icons) for this.

标签: androidflutterdart

解决方案


当您使用该包flutter_launcher_icons时,它会自动为应用程序生成不同的图标大小,这比仅将图像mipmap-xxxhdpi放入android/app/res.

例如,如果您添加flutter_launcher_iconspubspec.yaml

dev_dependencies: 
  flutter_launcher_icons: "^0.7.3"

flutter_icons:
  android: "launcher_icon" 
  ios: true
  image_path: "assets/icon/icon.png"

然后执行以下命令:

flutter pub get
flutter pub run flutter_launcher_icons:main

它将在res文件夹中为android和Assets.xcassetsios生成不同大小的所有图标。

在这里查看更多信息:

https://github.com/fluttercommunity/flutter_launcher_icons


推荐阅读