Skip to content

Dart run build_runner build fails on Flutter 3.44.0, source_gen 3.1.0 incompatible with analyzer 8.x #606

Description

@codaMW

Environment

  • Flutter: 3.44.0 (channel stable)
  • Dart SDK: 3.12.0
  • OS: Ubuntu 24.04 (WSL2)

Steps to Reproduce

git clone https://github.com/MostroP2P/mobile.git
cd mobile
flutter pub get
dart run build_runner build -d

Error

W source_gen-3.1.0/lib/src/constants/revive.dart:82:40: Error: The method
  'getInvocation' isn't defined for the type 'DartObjectImpl'.
   - 'DartObjectImpl' is from 'package:analyzer/src/dart/constant/value.dart'
  Try correcting the name to the name of an existing method, or defining a
  method named 'getInvocation'.
    final i = (object as DartObjectImpl).getInvocation();
                                         ^^^^^^^^^^^^^
E Failed to compile build script.

Root Cause

build_runner: ^2.4.0 resolves to build_runner 2.7.1 which pulls source_gen 3.1.0. That version calls DartObjectImpl.getInvocation() which was removed in analyzer 8.x. Flutter 3.44.0 ships Dart 3.12.0 which forces analyzer 8.4.1.

source_gen 3.2.0 does not exist on pub.dev, there is no released version of source_gen that supports analyzer >=8.0.0. Bumping build_runner or mockito constraints alone does not resolve this because the underlying source_gen package has not yet published a compatible release.

This was verified on the latest commit of main (e46854f3). Android Studio is not involved, this is pure Dart code generation and fails on a clean clone.

Impact

dart run build_runner build -d is a required setup step per the README. This blocks all contributors on Flutter stable 3.44.0 from building the app locally.

Possible Fix

Once source_gen publishes a release supporting analyzer 8.x, bumping build_runner and mockito to their latest versions should resolve this. Alternatively, replacing mockito with a code generation approach that does not depend on source_gen 3.x would also fix it. This is related to the broader dependency modernisation tracked in #512.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions