Skip to content
pubscout

flutter_gen_runner

5.15.0, released 4 months ago by wasabeef.jp

Generates strongly-typed Dart classes for Flutter assets, fonts, and colors to avoid string-based APIs.

Rock solid
$ flutter pub add flutter_gen_runner
Source repository

What it does

It reads your pubspec.yaml configuration and asset folders to generate safe, static reference classes. This eliminates string typos when loading images, fonts, or colors in your widgets.

AI-written summary of version 5.15.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You want type safety for asset paths, fonts, and colors in your Flutter app.
  • You want to avoid runtime errors from typos in string-based asset paths.

Skip it when

  • Your project does not use local assets, custom fonts, or generated color files.
  • You prefer completely manual string references for resources.

Strengths

  • Eliminates string-based asset paths and potential typos.
  • Integrates seamlessly with build_runner and pubspec.yaml configurations.
  • Supports specialized integrations like flutter_svg, rive, and lottie.

Weaknesses

  • Requires running a code generator whenever assets are added or modified.
  • Adds build-time overhead to your project development workflow.

Setup

Kind
Flutter widgets
Effort
Low
Code generation
Yes (build_runner)
Direct dependencies
9

Add flutter_gen_runner to your dev_dependencies and build_runner to your pubspec.yaml, then configure flutter_gen and run build_runner.

Widget build(BuildContext context) {
  return Assets.images.profile.image();
}

Alternatives

Packages that do the same job and could replace flutter_gen_runner.

  • pigeon

    Type-safe code generator for communication between Flutter and host platforms.

  • code_assets

    Provides the hook protocol specification for bundling native code with Dart packages.

  • riverpod_generator

    Generates Riverpod providers from annotated functions using build_runner.

  • mobx_codegen

    Generates MobX store boilerplate from @observable, @computed and @action annotations.

Works with

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