Skip to content
pubscout

source_helper

1.4.0, released 5 weeks ago by google.dev

Utilities to help with Dart source code generation and string literal formatting.

$ flutter pub add source_helper
Source repository

What it does

Provides utility functions and extensions for Dart source code generation. Includes features for properly generating String literals from any value and working with analyzer elements like DartType and constructors.

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

Use it when

  • You are building a custom Dart source code generator.
  • You need to handle string escaping and literal generation safely within builders.
  • You want helper methods for analyzer elements such as DartType and executable elements.

Skip it when

  • You are writing a standard Flutter application without custom code generators.
  • You are looking for general-purpose runtime utilities.

Strengths

  • Simplifies common tasks in custom source code generation.
  • Well-maintained compatibility with recent analyzer and source_gen packages.

Weaknesses

  • Niche utility only applicable to developers writing code generators.
  • No official support or guarantee from Google.

Setup

Kind
Pure Dart
Effort
Low
Code generation
Yes (build_runner)
Direct dependencies
2

Add source_helper as a dependency in pubspec.yaml alongside source_gen and analyzer.

Alternatives

Packages that do the same job and could replace source_helper.

  • code_builder

    A fluent, builder-based library for generating valid Dart code programmatically.

  • freezed

    Code generation for immutable classes, tagged unions, and cloning without boilerplate.

  • copy_with_extension

    Annotation for generating copyWith extensions code using copy_with_extension_gen.

  • flutter_gen_runner

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

Works with

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