flutter_launcher_icons 0.7.4

  • Readme
  • Changelog
  • Example
  • Installing
  • 100

Flutter Community: flutter_launcher_icons

Build Status pub package

Flutter Launcher Icons #

A command-line tool which simplifies the task of updating your Flutter app's launcher icon. Fully flexible, allowing you to choose what platform you wish to update the launcher icon for and if you want, the option to keep your old launcher icon in case you want to revert back sometime in the future.

✨ What's New #

Version 0.7.4 (28th Oct 2019)

  • Worked on suggestions from pub.dev

Version 0.7.3 (3rd Sept 2019)

  • Lot of refactoring and improving code quality (thanks to @connectety)
  • Added correct App Store icon settings (thanks to @richgoldmd)

Version 0.7.2 (25th May 2019)

  • Reverted back using old interpolation method

Version 0.7.1 (24th May 2019)

  • Fixed issue with image dependency not working on latest version of Flutter (thanks to @sboutet06)
  • Fixed iOS icon sizes which were incorrect (thanks to @sestegra)
  • Removed dart_config git dependency and replaced with yaml dependency

Version 0.7.0 (22nd November 2018)

  • Added check to ensure the Android file name is valid
  • Fixed issue where there was a git diff when there was no change
  • Fixed issue where iOS icon would be generated when it shouldn't be
  • Added support for drawables to be used for adaptive icon backgrounds
  • Added support for Flutter Launcher Icons to be able to run with it's own config file (no longer necessary to add to pubspec.yaml)

Version 0.6.1 (26th August 2018)

  • Upgraded dependencies so that it should now work with Dart 2.1.0

Version 0.6.0 (8th August 2018)

Version 0.5.0 (12th June 2018)

  • [Android] Support for adaptive icons added

:book: Guide #

1. Setup the config file

Add your Flutter Launcher Icons configuration to your pubspec.yaml or create a new config file called flutter_launcher_icons.yaml. An example is shown below. A more complex example can be found in the example project.

dev_dependencies: 
  flutter_launcher_icons: "^0.7.3"
  
flutter_icons:
  android: "launcher_icon" 
  ios: true
  image_path: "assets/icon/icon.png"

If you name your configuration file something other than flutter_launcher_icons.yaml or pubspec.yaml you will need to specify the name of the file when running the package.

flutter pub get
flutter pub run flutter_launcher_icons:main -f <your config file name here>

Note: If you are not using the existing pubspec.yaml ensure that your config file is located in the same directory as it.

2. Run the package

After setting up the configuration, all that is left to do is run the package.

flutter pub get
flutter pub run flutter_launcher_icons:main

If you encounter any issues please report them here.

In the above configuration, the package is setup to replace the existing launcher icons in both the Android and iOS project with the icon located in the image path specified above and given the name "launcher_icon" in the Android project and "Example-Icon" in the iOS project.

🔍 Attributes #

Shown below is the full list of attributes which you can specify within your Flutter Launcher Icons configuration.

  • android/ios

    • true: Override the default existing Flutter launcher icon for the platform specified
    • false: Ignore making launcher icons for this platform
    • icon/path/here.png: This will generate a new launcher icons for the platform with the name you specify, without removing the old default existing Flutter launcher icon.
  • image_path: The location of the icon image file which you want to use as the app launcher icon

  • image_path_android: The location of the icon image file specific for Android platform (optional - if not defined then the image_path is used)

  • image_path_ios: The location of the icon image file specific for iOS platform (optional - if not defined then the image_path is used)

Note: iOS icons should fill the entire image and not contain transparent borders.

The next two attributes are only used when generating Android launcher icon

  • adaptive_icon_background: The color (E.g. "#ffffff") or image asset (E.g. "assets/images/christmas-background.png") which will be used to fill out the background of the adaptive icon.

  • adaptive_icon_foreground: The image asset which will be used for the icon foreground of the adaptive icon

❓ Troubleshooting #

Listed a couple common issues with solutions for them

Generated icon color is different from the original icon

Caused by an update to the image dependency which is used by Flutter Launcher Icons.

Use #AARRGGBB for colors instead of ##AABBGGRR, to be compatible with Flutter image class.

Related issue

Image foreground is too big / too small

For best results try and use a foreground image which has padding much like the one in the example.

Related issue

👀 Example #

Video Example

Note: This is showing a very old version (v0.0.5)

Special thanks #

  • Thanks to Brendan Duncan for the underlying image package to transform the icons.
  • Big thank you to all the contributors to the project. Every PR / reported issue is greatly appreciated!

Changelog #

0.7.4 (28th Oct 2019) #

  • Worked on suggestions from pub.dev

0.7.3 (3rd Sept 2019) #

  • Lot of refactoring and improving code quality (thanks to @connectety)
  • Added correct App Store icon settings (thanks to @richgoldmd)

0.7.2 (25th May 2019) #

  • Reverted back using old interpolation method

0.7.1 (24th May 2019) #

  • Fixed issue with image dependency not working on latest version of Flutter (thanks to @sboutet06)
  • Fixed iOS icon sizes which were incorrect (thanks to @sestegra)
  • Removed dart_config git dependency and replaced with yaml dependency
  • Refactoring of code

0.7.0 (22nd November 2018) #

  • Now ensuring that the Android file name is valid - An error will be thrown if it doesn't meet the criteria
  • Fixed issue where there was a git diff when there was no change
  • Fixed issue where iOS icon would be generated when it shouldn't be
  • Added support for drawables to be used for adaptive icon backgrounds
  • Added support for Flutter Launcher Icons to be able to run with it's own config file (no longer necessary to add to pubspec.yaml)

0.6.1 (26th August 2018) #

  • Upgraded test package
  • Due to issue with dart_config not working with Dart 2.1.0, now using forked version of dart_config which contains fixes from both @v3rm0n and @SPodjasek

0.6.0 (8th August 2018) #

0.5.2 (19th June 2018) #

  • Previous release didn't fix adaptive icons, just prevented the error message from appearing. This should hopefully fix it!

0.5.1 (18th June 2018) #

  • Fix for adaptive icons

0.5.0 (12th June 2018) #

  • [Android] Support for adaptive icons added (Suggestion #23)

0.4.0 (9th June 2018) #

  • Now possible to generate icons for each platform with different image paths (one for iOS icon and a separate one for Android)

0.3.3 (28th May 2018) #

  • Upgraded dart image package dependency to 2.0.0 (issue #26)

0.3.2 (2nd May 2018) #

  • Bug fixing

0.3.1 (1st May 2018) #

  • Bug fixing

0.3.0 (1st May 2018) #

  • Fixed issue where icons produced weren't the correct size (Due to images not with a 1:1 aspect r ation)
  • Improved quality of smaller icons produced (Thanks to PR #17 - Thank you!)
  • Updated console printed messages to keep them consistent
  • Added example folder to GitHub project

0.2.1 (25th April 2018) #

  • Added extra iOS icon size (1024x1024)
  • Fixed iOS default icon name (Thanks to PR #15 - Thank you!)
  • Fixed issue #10 where creation of the icons was failing due to the target folder not existing

0.2.0 (18th January 2018) #

  • Ability to create new launcher icons without replacing the old ones added (#6)
  • Fixed issue with launcher icons for iOS not correctly being set

0.0.5 #

  • Quick Fix on if statement

0.0.4 #

  • Fixing strong mode error

0.0.3 #

  • Adding flutter as a dependency so its listed as a flutter package.

0.0.2 #

  • Fix Doc typo

0.0.1 #

  • Initial version, Resizes Icon to Android sizes only.

example/lib/main.dart

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        // This is the theme of your application.
        //
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to Colors.green and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",
        // or press Run > Flutter Hot Reload in IntelliJ). Notice that the
        // counter didn't reset back to zero; the application is not restarted.
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key key, this.title}) : super(key: key);

  // This widget is the home page of your application. It is stateful, meaning
  // that it has a State object (defined below) that contains fields that affect
  // how it looks.

  // This class is the configuration for the state. It holds the values (in this
  // case the title) provided by the parent (in this case the App widget) and
  // used by the build method of the State. Fields in a Widget subclass are
  // always marked "final".

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      // This call to setState tells the Flutter framework that something has
      // changed in this State, which causes it to rerun the build method below
      // so that the display can reflect the updated values. If we changed
      // _counter without calling setState(), then the build method would not be
      // called again, and so nothing would appear to happen.
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    // This method is rerun every time setState is called, for instance as done
    // by the _incrementCounter method above.
    //
    // The Flutter framework has been optimized to make rerunning build methods
    // fast, so that you can just rebuild anything that needs updating rather
    // than having to individually change instances of widgets.
    return Scaffold(
      appBar: AppBar(
        // Here we take the value from the MyHomePage object that was created by
        // the App.build method, and use it to set our appbar title.
        title: Text(widget.title),
      ),
      body: Center(
        // Center is a layout widget. It takes a single child and positions it
        // in the middle of the parent.
        child: Column(
          // Column is also layout widget. It takes a list of children and
          // arranges them vertically. By default, it sizes itself to fit its
          // children horizontally, and tries to be as tall as its parent.
          //
          // Invoke "debug paint" (press "p" in the console where you ran
          // "flutter run", or select "Toggle Debug Paint" from the Flutter tool
          // window in IntelliJ) to see the wireframe for each widget.
          //
          // Column has various properties to control how it sizes itself and
          // how it positions its children. Here we use mainAxisAlignment to
          // center the children vertically; the main axis here is the vertical
          // axis because Columns are vertical (the cross axis would be
          // horizontal).
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.display1,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_launcher_icons: ^0.7.4

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_launcher_icons/android.dart';
import 'package:flutter_launcher_icons/constants.dart';
import 'package:flutter_launcher_icons/custom_exceptions.dart';
import 'package:flutter_launcher_icons/ios.dart';
import 'package:flutter_launcher_icons/main.dart';
import 'package:flutter_launcher_icons/xml_templates.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
99
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
100
Learn more about scoring.

We analyzed this package on Mar 31, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6

Health suggestions

Format lib/android.dart.

Run dartfmt to format lib/android.dart.

Format lib/ios.dart.

Run dartfmt to format lib/ios.dart.

Format lib/main.dart.

Run dartfmt to format lib/main.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.0 <3.0.0
args ^1.5.0 1.6.0
image ^2.1.1 2.1.12
yaml ^2.1.15 2.2.0
Transitive dependencies
archive 2.0.13
charcode 1.1.3
collection 1.14.12
convert 2.1.1
crypto 2.1.4
meta 1.1.8
path 1.6.4
petitparser 3.0.2
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
xml 3.7.0 4.1.0
Dev dependencies
test ^1.6.3