How to change the application launcher icon on Flutter?

前端 未结 11 1793
名媛妹妹
名媛妹妹 2020-11-28 17:58

When I create an app with a flutter create command, the flutter logo is used as an application icon for both platforms.

If I want to change the app icon,

相关标签:
11条回答
  • 2020-11-28 18:02

    The one marked as correct answer, is not enough, you need one more step, type this command in the terminal in order to create the icons:

    flutter pub run flutter_launcher_icons:main

    0 讨论(0)
  • 2020-11-28 18:03

    You have to replace the Flutter icon files with images of your own. This site will help you turn your png into launcher icons of various sizes:

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

    0 讨论(0)
  • 2020-11-28 18:09

    Setting the launcher icons like a native developer

    I was having some trouble using and understanding the flutter_launcher_icons package. This answer is how you would do it if you were creating an app for Android or iOS natively. It is pretty fast and easy once you have done it a few times.

    Android

    Android launcher icons have both a foreground and a background layer.

    (image adapted from Android documentation)

    The easiest way to create launcher icons for Android is to use the Asset Studio that is available right in Android Studio. You don't even have to leave your Flutter project. (VS Code users, you might consider using Android Studio just for this step. It's really very convenient and it doesn't hurt to be familiar with another IDE.)

    Right click on the android folder in the project outline. Go to New > Image Asset. (Try right clicking the android/app folder if you don't see Image Asset as an option.) Now you can select an image to create your launcher icon from.

    Note: I usually use a 1024x1024 pixel image but you should certainly use nothing smaller that 512x512. If you are using Gimp or Inkscape, you should have two layers, one for the foreground and one for the background. The foreground image should have transparent areas for the background layer to show through.

    (lion clipart from here)

    This will replace the current launcher icons. You can find the generated icons in the mipmap folders:

    If you would prefer to create the launcher icons manually, see this answer for help.

    Finally, make sure that the launcher icon name in the AndroidManifest is the same as what you called it above (ic_launcher by default):

    application android:icon="@mipmap/ic_launcher"
    

    Run the app in the emulator to confirm that the launcher icon was created successfully.

    iOS

    I always used to individually resize my iOS icons by hand, but if you have a Mac, there is a free app in the Mac App Store called Icon Set Creator. You give it an image (of at least 1024x1024 pixels) and it will spit out all the sizes that you need (plus the Contents.json file). Thanks to this answer for the suggestion.

    iOS icons should not have any transparency. See more guidelines here.

    After you have created the icon set, start Xcode (assuming you have a Mac) and use it to open the ios folder in your Flutter project. Then go to Runner > Assets.xcassets and delete the AppIcon item.

    After that right-click and choose Import.... Choose the icon set that you just created.

    That's it. Confirm that the icon was created by running the app in the simulator.

    If you don't have a Mac...

    You can still create all of the images by hand. In your Flutter project go to ios/Runner/Assets.xcassets/AppIcon.appiconset.

    The image sizes that you need are the multiplied sizes in the filename. For example, Icon-App-29x29@3x.png would be 29 times 3, that is, 87 pixels square. You either need to keep the same icon names or edit the JSON file.

    0 讨论(0)
  • 2020-11-28 18:10

    Best way is to change launcher icons separately for both iOS and Android.

    Change the icons in iOS and Android module separately. The plugin produces different size icons from the same icon which are distorted.

    Follow this link: https://flutter.dev/docs/deployment/android

    0 讨论(0)
  • 2020-11-28 18:17

    When a new Flutter app is created, it has a default launcher icon. To customize this icon, you might want to check out the flutter_launcher_icons package.

    Alternatively, you can do it manually using the following steps. This step covers replacing these placeholder icons with your app’s icons:

    Android

    1. Review the Material Design product icons guidelines for icon design.

    2. In the <app dir>/android/app/src/main/res/ directory, place your icon files in folders named using configuration qualifiers. The default mipmap- folders demonstrate the correct naming convention.

    3. In AndroidManifest.xml, update the application tag’s android:icon attribute to reference icons from the previous step (for example, <application android:icon="@mipmap/ic_launcher" ...).

    4. To verify that the icon has been replaced, run your app and inspect the app icon in the Launcher.

    iOS

    1. Review the iOS App Icon guidelines.
    2. In the Xcode project navigator, select Assets.xcassets in the Runner folder. Update the placeholder icons with your own app icons.
    3. Verify the icon has been replaced by running your app using a flutter run.
    0 讨论(0)
  • 2020-11-28 18:20

    you can achieve this by using flutter_launcher_icons in pubspec.yaml

    another way is to use one for android and another one for iOS

    0 讨论(0)
提交回复
热议问题