assets_codegen 1.0.2 assets_codegen: ^1.0.2 copied to clipboard
Code generator for assets plugin. Using this with assets_annotation package and @AstHelp annotation. More info at README.md
assets_plugin #
Code generator for assets plugin
This plugin consist of three packages:
Getting Started #
This package should use with the asset_annotation package. The main idea of this is a generating dart class with fields, which can help you access your assets in code and give you autocomplete and static preload of text assets in one place. For an example of usage go-to example project. You can configure the generator in a build.ya?ml file of your project. At now the only thing is an extension of files, which can be preloaded. By default, it is a .txt and .json files, but you can pass your additional types in this manner:
targets:
$default:
builders:
assets_codegen:
options:
preload:
- your_file_type
- other_your_file_type
To use this package - install it and create file such as
import 'package:assets_annotations/assets_annotations.dart';
import 'package:flutter/services.dart'; // <== IT IMPORT IS REQUIRED FOR WORKING AUTO-PRELOAD FOR DEFINED FILE EXTENSIONS (json, txt, etc...)
part 'asset_helper.g.dart';
@AstHelp()
class AssetHelper with _$TextHelper {}
Plugin will search assets section in your pubspec.ya?ml file and watch directories, which is described there and deeper (recursive), after you run
flutter pub run build_runner build|watch [--delete-conflicting-outputs]
plugin will generate mixin near your annotated file-class.