source_gen
Source code generation builders and utilities for the Dart build system
4.3.0
5.7M downloads/mo
#134 most downloaded on pub.dev
dart-lang/source_gen
What this package is like to depend on
Last release 4 days ago
19 Aug 2026
Release timing varies
gaps range from 2 weeks to 6 months
Nearly every release is documented
notes for 142 of 143 stable releases
Nothing withdrawn
no release was ever pulled
12 years old
146 releases · first in 2015
11 releases in the last 12 months
see the full history below
Release timeline
146 releases · Jan 2015 to Aug 2026Releases
latest 60 of 146-
4.3.019 Aug 2026Release notes
Open source →- Support Dart 3.13 primary constructors and
newconstructor syntax in
TypeCheckerandConstantReader. - Require
sdk: ^3.11.0. - Require
analyzer: '>=14.0.0 <15.0.0'.
Release notes
Open source →- Support Dart 3.13 primary constructors and
newconstructor syntax inTypeCheckerandConstantReader. - Require
sdk: ^3.11.0. - Require
analyzer: '>=14.0.0 <15.0.0'.
- Support Dart 3.13 primary constructors and
-
4.2.423 Jul 2026 -
4.2.329 Apr 2026 -
4.2.220 Mar 2026 -
4.2.113 Mar 2026Release notes
Open source →- Fix
UnresolvedAnnotationExceptionto include the name of the annotation in
the message. - Require
build: '>=3.0.2 <5.0.0' - Require
dart_style: ^3.1.2 - Require
sdk: ^3.9.0
Release notes
Open source →- Fix
UnresolvedAnnotationExceptionto include the name of the annotation in the message. - Require
build: '>=3.0.2 <5.0.0' - Require
dart_style: ^3.1.2 - Require
sdk: ^3.9.0
- Fix
-
4.2.020 Jan 2026 -
4.1.213 Jan 2026 -
4.1.119 Nov 2025 -
4.1.018 Nov 2025Release notes
Open source →- Add
TypeChecker.typeNamedLiterally. It's likeTypeChecker.typeNamed,
but takes aStringinstead of aType.
Release notes
Open source →- Add
TypeChecker.typeNamedLiterally. It's likeTypeChecker.typeNamed, but takes aStringinstead of aType.
- Add
-
4.0.209 Oct 2025Release notes
Open source →- Bug fix: fix possible null pointer exception in
TypeChecker.typeNamedon
invalid code.
Release notes
Open source →- Bug fix: fix possible null pointer exception in
TypeChecker.typeNamedon invalid code.
- Bug fix: fix possible null pointer exception in
-
4.0.104 Sep 2025 -
4.0.027 Aug 2025Release notes
Open source →- Breaking Change: remove
TypeChecker.fromRuntime, useTypeChecker.typeNamedinstead. This removes all use ofdart:mirror, so builders usingsource_gencan be AOT compiled for better performance. - Keep
// GENERATED FILEcomments on the first line.
- Breaking Change: remove
-
3.1.011 Aug 2025Release notes
Open source →- Prepare to stop using
dart:mirrors: deprecateTypeChecker.fromRuntime. It will be removed in version4.0.0. AddTypeChecker.typeNamedwhich is the recommended replacement. - Prepare to stop using
dart:mirrors: addinPackageandinSdkparameters toGenerateForAnnotation. These will start being used in version4.0.0when it switches toTypeChecker.typeNamed. InvalidGenerationSourcesupport forFragment,ElementDirectiveandAnnotatable.- Allow
analyzer: '>=7.4.0 <9.0.0'.
- Prepare to stop using
-
3.0.017 Jul 2025Release notes
Open source →- Breaking Change: use the new
element2APIs inanalyzer. Builders that do resolution need to switch to the new API, see https://github.com/dart-lang/sdk/blob/main/pkg/analyzer/doc/element_model_migration_guide.md. For questions please use https://github.com/dart-lang/build/discussions. - Breaking Change: annotations are now reported separately for elements
and directives. If you use
TypeChecker().annotatedWith(), see also the newTypeChecker().libraryDirectivesAnnotatedWith(). If you useGeneratorForAnnotationsee the newgenerateForAnnotatedDirective. - Require
build: ^3.0.0 - Updated the minimum package versions for a number of dependencies.
- Require Dart 3.7.0
- Update the GeneratorForAnnotation optimization to skip files with well known
annotation names such as
override,Deprecated, andpragma.
- Breaking Change: use the new
-
3.0.0-dev27 Jun 2025 pre-releaseRelease notes
Open source →- Breaking Change: use the new
element2APIs inanalyzer. Builders that do resolution need to switch to the new API, see https://github.com/dart-lang/sdk/blob/main/pkg/analyzer/doc/element_model_migration_guide.md. For questions please use https://github.com/dart-lang/build/discussions. - Updated the minimum package versions for a number of dependencies.
- Require Dart 3.7.0
- Breaking Change: use the new
-
2.0.017 Dec 2024Release notes
Open source →- Breaking Change: Change
formatOutputfunction to accept a language version parameter. - Formatting Change: Generated code will no longer apply any fixes by default (previously it would apply the single cascades statements fix). The new formatter does not support applying fixes.
- Document deduplication behavior for the output of
GeneratorForAnnotation.generateForAnnotatedElement. - Support all the glob quotes.
- Require
analyzer: '>=6.9.0 <8.0.0' - Support the latest
package:dart_style LibraryBuilder,PartBuilder, andSharedPartBuildernow take an optionalwriteDescriptionsboolean. When set tofalse, headers and generator descriptions for the files will not be included in the builder output.- Include
//dart format width=80comments in files generated by aLibraryBuilderorPartBuilderand formatted with the default callback. - Require Dart 3.6.0
- Breaking Change: Change
-
1.5.013 Dec 2023Release notes
Open source →- Add
throwOnUnresolvedconfiguration to theGeneratorForAnnotationconstructor. - Rename
InvalidGenerationSourceErrortoInvalidGenerationSource. Change from a subtype ofErrorto a subtype ofException. This may be breaking if a builder relies on aon Exception catchto ignore this error.
- Add
-
1.4.029 Jun 2023Release notes
Open source →- Require Dart 3.0
- Support the latest
package:analyzer. - Add a
nodeargument toInvalidGenerationSourceErrorto allow finding the source location from anAstNodeover anElement.
-
1.3.211 May 2023 -
1.3.109 May 2023Release notes
Open source →- Always use a Uri in
part ofdirectives (previously a name would be used if the library had a non-empty one).
- Always use a Uri in
-
1.3.005 May 2023Release notes
Open source →- Add support for
build_extensionsconfiguration of builders producing multiple files. For example:build_extensions: { '.dart': ['.stub.dart', '.web.dart', '.vm.dart'] } - Avoid throwing when a type without a backing class is checked with
TypeChecker. - Include imports, exports, and part directives in
LibraryReader.allElements. This allowsGeneratorForAnnotationto target annotated directives.
- Add support for
-
1.2.731 Jan 2023Release notes
Open source →- Update the value of the pubspec
repositoryfield. - Require Dart SDK version
2.18. - Fix type-checking mixin elements with
TypeChecker.
- Update the value of the pubspec
-
1.2.611 Oct 2022 -
1.2.520 Sep 2022 -
1.2.420 Sep 2022 -
1.2.313 Sep 2022 -
1.2.214 Apr 2022Release notes
Open source →- Enable the fix for single cascade statements when formatting Dart code.
- Individual builders can opt out of this by providing a custom
formatOutputfunction to thePartBuilderorLibraryBuilderconstructors.
- Individual builders can opt out of this by providing a custom
- Allow analyzer version 4.x.
- Enable the fix for single cascade statements when formatting Dart code.
-
1.2.116 Dec 2021Release notes
Open source →- Allow reviving constants which are static fields defined on the class which represents their type. Previously we checked this pattern only for enums, however there are enum-like usages in classes which are not enums.
- Allow the latest version of
package:analyzer.
-
1.2.029 Nov 2021Release notes
Open source →- Include the
LibraryElementinLibraryReader.allElements,LibraryReader.annotatedWith, andLibraryReader.annotatedWithExact. RunGeneratorForAnnotationgenerators on library elements when thelibrarystatement has the annotation. - Add support for
build_extensionsconfiguration to thePartBuilderandLibraryBuilder. You must forward theBuilderOptionsobject to the super constructor for this to work. - Fix a bug finding source locations for reporting unresolved annotations on parameters.
- Fix a bug checking for
partstatements on Windows.
- Include the
-
1.1.127 Sep 2021 -
1.1.019 Aug 2021Release notes
Open source →- Add the
build_extensionsoption tocombining_builder, allowing output files to be generated into a different directory.
- Add the
-
1.0.521 Jul 2021Release notes
Open source →- Fix a bug with reviving constant expressions which are fields defined on a different class than their type (but in the same library).
-
1.0.419 Jul 2021 -
1.0.313 Jul 2021 -
1.0.210 Jun 2021Release notes
Open source →- Fix
TypeChecker.fromRuntimeTypefor types that come from non-package uris.
- Fix
-
1.0.126 May 2021Release notes
Open source →- Improve the error message for a missing part directive.
- Upgrade to
package:analyzerversion1.7.0.
-
1.0.018 Mar 2021Release notes
Open source →- Migrate to null safety.
- Drop deprecated APIs:
ConstantReader.isAny.ConstantReader.anyValue.LibraryReader.classElements.
-
0.9.1008 Dec 2020Release notes
Open source →- Optimize for the case where we have only GeneratorForAnnotation generators, and we know there are no annotations present in the file at all.
-
0.9.10+114 Dec 2020Release notes
Open source →- Fix a bug in the early bailout optimization where it wouldn't check for annotations in part files.
-
0.9.10+210 Feb 2021Release notes
Open source →- Expand allowed versions for the glob package as source_gen is compatible to break circular dependency issues in the ecosystem.
-
0.9.10+318 Feb 2021 -
0.9.10+415 Mar 2021Release notes
Open source →- Upgrade to
package:buildversion2.0.0. - Handle alias types with
DartType.aliasElement.
- Upgrade to
-
0.9.10+505 Jan 2022 -
0.9.902 Dec 2020 -
0.9.827 Oct 2020Release notes
Open source →- Add support for
allowSyntaxErrorsflag introduced inpackage:buildversion1.4.0. - Update minimum Dart SDK to
2.10.0.
- Add support for
-
0.9.7+122 Sep 2020 -
0.9.610 Jul 2020Release notes
Open source →- Add support for
SetinConstantReader.- Updated
isLiteralandliteralValueto handleSet. - Added
isSetandsetValuemembers.
- Updated
- Include matching Dart language version overrides in generated parts if the source library has a language version override.
- Streamlined error handling in all builders. There should be no user-visible behavior change.
- Improve the error message when source code formatting fails.
- Update minimum Dart SDK to
2.7.0. - Changed the behavior of
LibraryReader.allElementsto include extensions.
- Add support for
-
0.9.524 Feb 2020Release notes
Open source →-
Add support for an
ignore_for_fileoption tocombining_builder. -
Expand documentation for
GeneratorForAnnotationto make it clear that it only targets elements at the top level of a library.
-
-
0.9.415 Jan 2019Release notes
Open source →- Use
ParsedLibraryResultto find source spans for unresolvable annotations.
- Use
-
0.9.4+101 Feb 2019 -
0.9.4+203 Apr 2019 -
0.9.4+320 Jul 2019 -
0.9.4+421 Aug 2019 -
0.9.4+526 Sep 2019Release notes
Open source →- Fix a bug for finding the element for a function with recent versions of
analyzer.
- Fix a bug for finding the element for a function with recent versions of
-
0.9.4+629 Oct 2019 -
0.9.4+702 Jan 2020Release notes
Open source →- Fix an exception during error reporting when the
Elementreported is in a summary file rather than a source file.
- Fix an exception during error reporting when the
-
0.9.312 Dec 2018Release notes
Open source →- Rename
LibraryReader.classElementstoLibraryReader.classesto better reflect the behavior. Deprecate the old name. - Add
LibraryReader.enums.
- Rename
-
0.9.206 Dec 2018Release notes
Open source →- Avoid using the AST analyzer model from
LibraryReader. - Don't create part files with no corresponding library.
- Update analyzer constraint to allow 0.34.x.
- Avoid using the AST analyzer model from
-
0.9.110 Sep 2018Release notes
Open source →-
The result of
ConstantReader.revive()now returns aRevivablethat assumes access to a private class, constructor, or function instead ofnullwhere possible. This allows generators that usepartfiles to still use this functionality and allows generators that use separate libraries to emit more actionable error messages (i.e."cannot use private class _X"). -
Revivable.isPrivatenow returnstruewhen the underlying class was public but the constructor was private, or theRevivablewas pointing to a top-level or static private field or method. Previously it was onlytruewhen referencing a private class.
-
-
0.9.1+125 Sep 2018