Mek Assets

Automatically generate dart classes / flutter pubspec entries for your assets files.

Usage

  1. Activate: dart/flutter pub global activate mek_assets

  2. Create mek_assets.yaml file or add in your pubspec.yaml file:

mek_assets:
  # It supports generating assets in a `single` class, into `multi` classes based on directory or `tree` classes structure based on directory
  format: multi # single, multi, tree
  # The various assets groups
  groups:
    # Path of assets
    - input_dir: assets
      prefix_class_name: R
      output_file_name: r
  1. Optional: Add these comments to pubspec.yaml to automatically generate all the entries needed to flutter
flutter:
  assets:
    - ...
    # mek_assets GENERATED CODE - DO NOT MODIFY BY HAND
    - The auto generated code will be added here, copy paste this section
    # mek_assets
  1. You can generate index files with: <dart|flutter> pub global run mek_assets build

Advance and Package Usage

mek_assets:
  # The page width uses when the dart code is generated
  page_width: 80
  # Add the package name to the paths of the assets
  package: awesome_assets

  groups:
    - input_dir: assets
      # Define what elements to include in the group, use Glob format
      include:
        # You can define specific export assets files
        - '**.png'
      # Define what elements to exlude in the group, use Glob format
      exclude: [ '**.svg' ]
      # Prefix of the classes that contains the assets. Defaults nothing.
      prefix_class_name: R
      # Name of the main class that contains the assets. Defaults input directory name.
      class_name: AwesomeAssets
      # Create a map of all items contained in the group
      create_map_files: true
      # Directory where to save the generated files. Defaults `lib`
      output_dir: lib/src
      # Generated file name. Defaults input directory name 
      output_file_name: 'r'

Single / Tree

      class_name: R
      output_file_name: r

Multi

      prefix_class_name: R
      output_file_name: r

Features and bugs

Please file feature requests and bugs at the issue tracker.

Extra

  • index_generator: Automatically generate index / barrel files with all the exports needed for your library.
  • mek_data_class: Generate hashCode, ==, toString, copyWith and change methods with low code.

Libraries

mek_assets
Support for doing something awesome.