assets_scanner
2.0.0, released 6 years ago by an unverified publisher
Generates Dart constants for your asset paths with image preview support.
What it does
Scans your project assets and generates an r.dart file containing type-safe constants for asset paths. It also includes comments to allow image previewing by hovering over the constants in supported IDEs.
AI-written summary of version 2.0.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You want to avoid typos when referencing asset paths in your code
- You want IDE hover previews for your image assets
Skip it when
- You prefer manual string paths or do not use build_runner
- You do not use asset files in your project
Strengths
- Reduces spelling errors for asset paths
- Supports image previewing via IDE hover
- Customizable options via assets_scanner_options.yaml
Weaknesses
- Requires running build_runner to update constants
- Limited to what can be statically generated from pubspec assets
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- Yes (build_runner)
- Direct dependencies
- 5
Add to dev_dependencies and run flutter packages pub run build_runner build.
class R {
static const package = "example";
static const baseline_3d_rotation_white = "assets/baseline_3d_rotation_white.png";
}Alternatives
Packages that do the same job and could replace assets_scanner.
- mason
Dart template generator for quick file creation
89Compare - protobuf
Provides runtime support for Dart protocol buffer messages generated by protoc_plugin.
84Compare - pubspec_extract
Extracts Dart pubspec.yaml file and generates pubspec.dart at build time
75Compare - winmd
Inspect and generate Windows Metadata (.winmd) files based on ECMA-335.
70Compare
Works with
Packages commonly used together with assets_scanner: ones it builds on, ones built on it, and its own family.
- yamlassets_scanner depends on itA Dart library for parsing YAML documents into Dart data structures.
- globassets_scanner depends on itA file and directory globbing library that supports Bash-style path matching and listing.
- buildassets_scanner depends on itPackage for authoring build_runner compatible code generators.
- build_runnerUsed togetherA build system for Dart code generation and modular compilation.