0

In android and ios, there is an option to create or customize image shape, background, etc. For an app icon. But in a flutter, it's not possible.

I used this library,

flutter_launcher_icons

but they only set icon(not customize for both android ios).

Because if it is possible in a flutter, By using any tool or plugin. It's better.

Shirsh Shukla
  • 5,491
  • 3
  • 31
  • 44
  • have you tried this https://romannurik.github.io/AndroidAssetStudio/icons-launcher.html @shirsh shukla – Abhijith Nov 20 '20 at 05:15
  • yes in android they are perfect, but what about ios. is this work for both – Shirsh Shukla Nov 20 '20 at 05:24
  • I am not familiar with ios,but i had project that uses same image in ios also,the ios part is done by another guy,he said he used the same image that done with this..@shirsh shukla – Abhijith Nov 20 '20 at 05:27
  • ok,but do you know any plugin or tool that create or customize icon in IDE(for flutter).like android uses image assets. – Shirsh Shukla Nov 20 '20 at 05:31
  • No i have using above link to customize icon,may be you can customize the icon with above link then copy paste the customized image to required folder in ios and android@shirsh shukla – Abhijith Nov 20 '20 at 05:35
  • flutter_launcher_icons plugin has some attributes like adaptive_icon_background and adaptive_icon_foreground for customization, did you try that? – ajay Nov 20 '20 at 05:46
  • yes i use this,but this is for only android. – Shirsh Shukla Nov 20 '20 at 05:53

2 Answers2

0

I assume that you want to show different launcher icon on both platform (android, ios). If yes, kindly take a look at this post

SY L
  • 25
  • 6
  • no, I want a single(tool, plugin, or any other way) that they create or customize the icon for both the platforms(android, ios) in a flutter. – Shirsh Shukla Nov 20 '20 at 05:10
0

Not long ago, I wrote a sh script to create my flutter app icon. Now I can share it, but I don’t know if it can meet your requirements, you can give it a try.

This script need a source 1024x1024 App Icon first.

Save the content of the following script as a .sh file. e.g. flutter_app_icon_convert.sh.

Don't forget to add executable permission.

chmod +x flutter_app_icon_convert.sh

Then install the ImageMagick image tool if you not install it yet.

brew install imagemagick

And then use the script to create the flutter app icons (Both Android and iOS).

In your flutter project folder:

sh your_path/flutter_app_icon_convert.sh your_source_app_icon_1024x1024.png .

#!/bin/sh

# echo font color
# https://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux
#
# ANSI escape codes:
#
# Black        0;30     Dark Gray     1;30
# Red          0;31     Light Red     1;31
# Green        0;32     Light Green   1;32
# Brown/Orange 0;33     Yellow        1;33
# Blue         0;34     Light Blue    1;34
# Purple       0;35     Light Purple  1;35
# Cyan         0;36     Light Cyan    1;36
# Light Gray   0;37     White         1;37
#
#
RED='\033[0;31m'
GREEN='\033[0;32m'
NO_COLOR='\033[0m'

convertImage() {
  src=$1
  srcdir=$(dirname "$src")

  if test -d "$2"; then
    des="$(
      cd "$2" || exit
      pwd
    )"
    build512=0
  else
    build512=1
    des="$(
      cd "${srcdir}" || exit
      pwd
    )/AppIcons"
  fi

  echo "Icons will be saved to :${GREEN}${des}${NO_COLOR}"
  mkdir -p "$des"

  echo 'creating ios icons...'

  ios=${des}/ios/Runner/Assets.xcassets/AppIcon.appiconset
  mkdir -p "$ios"

  convert -resize 20x20 "$src" "$ios"/Icon-App-20x20@1x.png
  convert -resize 40x40 "$src" "$ios"/Icon-App-20x20@2x.png
  convert -resize 60x60 "$src" "$ios"/Icon-App-20x20@3x.png
  convert -resize 29x29 "$src" "$ios"/Icon-App-29x29@1x.png
  convert -resize 58x58 "$src" "$ios"/Icon-App-29x29@2x.png
  convert -resize 87x87 "$src" "$ios"/Icon-App-29x29@3x.png
  convert -resize 40x40 "$src" "$ios"/Icon-App-40x40@1x.png
  convert -resize 80x80 "$src" "$ios"/Icon-App-40x40@2x.png
  convert -resize 120x120 "$src" "$ios"/Icon-App-40x40@3x.png
  convert -resize 120x120 "$src" "$ios"/Icon-App-60x60@2x.png
  convert -resize 180x180 "$src" "$ios"/Icon-App-60x60@3x.png
  convert -resize 76x76 "$src" "$ios"/Icon-App-76x76@1x.png
  convert -resize 152x152 "$src" "$ios"/Icon-App-76x76@2x.png
  convert -resize 167x167 "$src" "$ios"/Icon-App-83.5x83.5@2x.png
  convert -resize 1024x1024 "$src" "$ios"/Icon-App-1024x1024@1x.png

  echo 'creating android icons...'

  android=${des}/android/app/src/main/res
  mkdir -p "$android"
  mkdir -p "$android"/mipmap-xxxhdpi
  mkdir -p "$android"/mipmap-xxhdpi
  mkdir -p "$android"/mipmap-xhdpi
  mkdir -p "$android"/mipmap-mdpi
  mkdir -p "$android"/mipmap-hdpi

  convert -resize 192x192 "$src" "$android"/mipmap-xxxhdpi/ic_launcher.png
  convert -resize 144x144 "$src" "$android"/mipmap-xxhdpi/ic_launcher.png
  convert -resize 96x96 "$src" "$android"/mipmap-xhdpi/ic_launcher.png
  convert -resize 48x48 "$src" "$android"/mipmap-mdpi/ic_launcher.png
  convert -resize 72x72 "$src" "$android"/mipmap-hdpi/ic_launcher.png

  echo ''
  if [ $build512 = 1 ]; then
    convert -resize 512x512 "$src" "$des"/Icon-App-512x512.png
  else
    echo 'if you want to create an extra 512x512 icon, use command:'
    echo "convert -resize 512x512 $src $srcdir/Icon-App-512x512.png"
    echo ''
  fi

  echo "${GREEN}Done${NO_COLOR}."
  echo ''
}

printHelp() {
  echo 'This script use "ImageMagick" image tool to convert 1024x1024 App Icon to flutter Android and iOS icons.'
  echo 'So you need install "ImageMagick" first: https://imagemagick.org/script/download.php'
  echo 'This script can accept 2 parameters. The first is your srouce App Icon, the size should be 1024x1024.'
  echo 'The second parameter is optional and specifies the save path of the generated icons. If not specified, it will be saved to the folder where the source icon is located, and an additional 512x512 icon will be generated.'
}

if command -v convert >/dev/null 2>&1; then
  if test "$1" = "-h" -o "$1" = "--help"; then
    printHelp
  elif test -f "$1"; then
    convertImage "$1" "$2"
  else
    echo "${RED}Error${NO_COLOR}: please provide your 1024x1024 source app icon file."
    echo ''
    printHelp
  fi
else
  echo "${RED}Error${NO_COLOR}:ImageMagick convert image tools not installed,you can use homebrew to intall it:"
  echo 'brew install imagemagick'
fi
zhpoo
  • 726
  • 4
  • 10