Skip to content

Upgrading source_gen 2 to 3

Breaking2.0.0 → 3.1.0Breaking1Platform2Deprecated1New2Changed4

BreakingUpgrade verdict

1 breaking change and 2 platform requirement changes.

  • Code generators that look up type information must be updated to the analyzer's new element model.
  • You need Dart SDK 3.7.0 or newer to use this version.
  • You need Dart 3.7.0 or newer to use this version.
  • A way of looking up types that relies on runtime reflection is being retired. Use the new lookup method instead.
4 items need code or config changes

source_gen publishes an official migration guide for version 3. It covers more than the release notes do.

Migration guide ↗

Dart SDK requirement changed in 3.0.0-dev: ^3.6.0 → ^3.7.0.

Breaking1
Uses the new element2 APIs in analyzer; builders that do resolution must switch to the new API.
element2
Platform2
Requires Dart 3.7.0.
Requires Dart 3.7.0.
Deprecated1
Deprecates TypeChecker.fromRuntime ahead of removal in 4.0.0 and adds TypeChecker.typeNamed as the recommended replacement.
TypeChecker.fromRuntimeTypeChecker.typeNameddart:mirrors