App Icon Generation - tungpham6195/flutter GitHub Wiki

Refer this package

Add flutter_launcher_icons to your pubspec.yaml under dev_dependencies:

dev_dependencies:
  flutter_launcher_icons: <latest_version>

Then run flutter pub get

Asset location:

app_icon_assets

For Android 8.0 (API 26), you need to follow the adaptive icon guides: Refer this.

So you need to make sure that your icon be inside of this boundary. Use this tempate.

screenshot

Create .yaml file for each flavors:

  • .yaml file name should be following this format flutter_launcher_icons-<flavor>.yaml

  • flavor: it should be exactly your flavor name, e.g: flutter_launcher_icons-dev.yaml

    app_icon_flavor_configuration

Update .yaml file configuration:

This is example

  • For development flavor

     flutter_icons:
       image_path_android: "assets/launcher_icon/android/icon_dev.png"
       image_path_ios: "assets/launcher_icon/ios/icon_dev.png"
       android: "ic_launcher"
       ios: true
       adaptive_icon_background: "#ffffff"
       adaptive_icon_foreground: "assets/launcher_icon/android/icon_dev.png"
       remove_alpha_ios: true
  • For production flavor

     flutter_icons:
       image_path_android: "assets/launcher_icon/android/icon_prod.png"
       image_path_ios: "assets/launcher_icon/ios/icon_prod.png"
       android: "ic_launcher"
       ios: true
       adaptive_icon_background: "#ffffff"
       adaptive_icon_foreground: "assets/launcher_icon/android/icon_prod.png"
       remove_alpha_ios: true

Write your script:

  • Create a script file: generate_icon.sh

     flutter pub run flutter_launcher_icons:main -f flutter_launcher_icons-dev.yaml

    You can choose 1 of those configuration files to use for generate app icon, flutter_launcher_icons will generate icons for all flavors if you have configuration for those flavors

    E.g: I have 2 configurations for flavor prod and dev, but I just run with dev (flutter_launcher_icons-dev.yaml), flutter_launcher_icons also generate icons for prod

    app_icon_build_script

⚠️ **GitHub.com Fallback** ⚠️