style: effective dart

A simple and easy command-line generation tool generating image assets keys for Dart and Flutter projects. Inspired by easy_localization:generate.

Motivation

In Flutter you need use asset path string directly:

Image.asset('assets/images/image.png')

You trust the human factor to validate the path correctness to the asset. It is not safe. If you get wrong you know it later in runtime only.

The safe way to pass it to generation tool:

Image.asset(ImagesKeys.image_png)

Installation

Add to your pubspec.yaml:

dependencies:
  images_keys: <last_version>

Usage

You can simply get information about command line arguments. Open terminal in your project path and run command:

pub run images_keys:images_keys -h

for flutter:

flutter pub run images_keys:images_keys -h

Command line arguments

ArgumentsShortDefaultDescription
--help-hHelp info
--source-dir-Sassets/imagesFolders containing image files
--output-dir-Olib/generatedOutput folder stores for the generated file
--output-file-oimages_keys.images_keys.dartOutput file name

See example for more details.