[Flutter]アプリアイコンを変更する

広告Flutter
2024年1月14日2024年3月11日

アプリのアイコンはiOSとAndroid用のイメージを生成して、各プラットフォームにアプリのアイコンを設定する必要がありますが flutter_launcher_iconsパッケージを利用することで一括で変更することができます。

1.flutter_launcher_iconsをインストール

flutter_launcher_icons | Dart package

A package which simplifies the task of updating your Flutter app's launcher icon.pub.devpub.dev
flutter_launcher_icons | Dart package
flutter pub add -d flutter_launcher_icons
pubspec.yaml
dev_dependencies:
  flutter_launcher_icons: ^0.13.1

2.設定

pubspec.yamlに画像パスを設定します。

pubspec.yaml
dev_dependencies:
  flutter_launcher_icons: "^0.13.1"
flutter_launcher_icons:
  android: true 
  ios: true
  image_path: "assets/icon.png"
  remove_alpha_ios: true
  

image_pathは任意の画像配置パスを指定します。

3.コマンドを実行

アイコン画像を生成します。

flutter pub run flutter_launcher_icons