Skip to content
pubscout

assets_scanner

2.0.0, released 6 years ago by an unverified publisher

Generates Dart constants for your asset paths with image preview support.

$ flutter pub add assets_scanner
Source repository

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

  • protobuf

    Provides runtime support for Dart protocol buffer messages generated by protoc_plugin.

  • pubspec_extract

    Extracts Dart pubspec.yaml file and generates pubspec.dart at build time

  • winmd

    Inspect and generate Windows Metadata (.winmd) files based on ECMA-335.

Works with

Packages commonly used together with assets_scanner: ones it builds on, ones built on it, and its own family.