Daassets

Free

mauriciotogneri

(Project Owner)
(Project Contributors)

General Details

3 RATINGS
REGISTRAR
Oct 13th 19 REGISTERED ON

Additional Details

Source Code DOWNLOAD
NA VERSION
Sep 06, 2019 Last Updated

Daassets

A Flutter package to automatically generate a class containing references to all assets in your project.

Installation

Add the following dependencies to your pubspec.yaml:

dev_dependencies:
  daassets: ^1.0.0

Example

Define your assets

In your pubspec.yaml file:

flutter:

  assets:

    - assets/icon/            # imports all files in that directory
    - assets/icon/close.png   # imports that specific file

Generating Dart code

To generate the Dart file containing all assets, run the following command:

flutter pub pub run daassets:daassets.dart PUBSPEC_FILE_PATH OUTPUT_FILE_PATH

For example:

flutter pub pub run daassets:daassets.dart ./pubspec.yaml ./lib/assets.dart

Using generated code

The generated class contains static constants that you can use anywhere in your project.

Image.asset(Assets.ICON_CLOSE);