-
-
Notifications
You must be signed in to change notification settings - Fork 301
Description
When using freezed 3.2.3 with Dart 3.10.4 (Flutter 3.38.5 stable), the Dart compiler fails to recognize mixin implementations generated by freezed, resulting in compilation errors for ALL @freezed classes.
freezed_bug_report_20251220_132618.tar.gz
.
Error Message
error • Missing concrete implementation of 'getter mixin _$ClassName on Object.propertyName'
• non_abstract_class_inherits_abstract_member
Key observation: Error says "on Object" instead of "on ClassName", suggesting the mixin is not being applied correctly to the class.
📋 Environment
- freezed: 3.2.3
- freezed_annotation: 3.1.0
- build_runner: 2.10.4
- Dart SDK: 3.10.4 (stable) - Flutter 3.38.5
- OS: Linux (Arch Linux, kernel 6.18.2)
- Also tested with:
- Dart 3.11.0 (Flutter 3.40.0-0.2.pre beta) → Same error
- Dart 3.6.0 (Flutter 3.27.1 stable) → Works fine with freezed 2.x
🔬 Minimal Reproducible Example
I've created a minimal project that reproduces the issue:
Project Structure
freezed_test_minimal/
├── lib/
│ └── test_model.dart
├── pubspec.yaml
└── (generated files)
pubspec.yaml
name: freezed_test_minimal
description: Minimal reproducible example for freezed 3.2.3 + Dart 3.10.4 bug
environment:
sdk: '>=3.10.0 <4.0.0'
flutter: '>=3.38.0'
dependencies:
flutter:
sdk: flutter
freezed_annotation: ^3.1.0
dev_dependencies:
flutter_test:
sdk: flutter
freezed: ^3.2.3
build_runner: ^2.10.4lib/test_model.dart
import 'package:freezed_annotation/freezed_annotation.dart';
part 'test_model.freezed.dart';
@freezed
class TestModel with _$TestModel {
const factory TestModel({required String id}) = _TestModel;
}Steps to Reproduce
# 1. Create project
flutter create freezed_test_minimal
cd freezed_test_minimal
# 2. Add dependencies
flutter pub add freezed_annotation
flutter pub add --dev freezed build_runner
# 3. Create test model (see above)
# 4. Generate code
dart run build_runner build --delete-conflicting-outputs
# ✅ SUCCESS: Built with build_runner/jit in 5s; wrote 1 output.
# 5. Analyze
flutter analyze lib/test_model.dart
# ❌ ERROR: Missing concrete implementation of 'getter mixin _$TestModel on Object.id'🔍 Analysis of Generated Code
The generated test_model.freezed.dart file appears structurally correct:
Mixin definition (line 15-41):
mixin _$TestModel {
String get id; // ✅ Getter defined
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$TestModelCopyWith<TestModel> get copyWith => ...;
@override
bool operator ==(Object other) { ... }
@override
int get hashCode => Object.hash(runtimeType, id);
@override
String toString() => 'TestModel(id: $id)';
}Concrete class (line 208-237):
class _TestModel implements TestModel {
const _TestModel({required this.id});
@override
final String id; // ✅ Property implemented
@override
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$TestModelCopyWith<_TestModel> get copyWith => ...;
// All other methods implemented correctly
}Source class:
@freezed
class TestModel with _$TestModel { // Mixin applied
const factory TestModel({required String id}) = _TestModel;
}Observation
The generated code follows the exact pattern documented in freezed's README:
- ✅ Mixin
_$TestModeldefines getters - ✅ Concrete class
_TestModelimplements all properties - ✅ Source class
TestModeluseswith _$TestModel
But: Dart 3.10.4 compiler does not recognize the mixin implementation.
🧪 Additional Testing
Test 1: Large Project (327 errors)
Original issue discovered in a large Flutter project with:
- 20+ @freezed models (69 @freezed classes total)
- Riverpod 3.x state management
- Clean Architecture pattern
Result: All 327 compilation errors related to freezed mixins.
Test 2: Dart Versions
| Dart Version | Flutter Version | freezed Version | Result |
|---|---|---|---|
| 3.6.0 | 3.27.1 stable | 2.5.7 | ✅ Works |
| 3.10.4 | 3.38.5 stable | 3.2.3 | ❌ Fails |
| 3.11.0 | 3.40.0-0.2.pre beta | 3.2.3 | ❌ Fails |
Test 3: Clean Operations
Attempted fixes (all failed):
flutter cleandart run build_runner cleanrm -rf .dart_tool/build- Multiple regenerations
- Fresh Flutter SDK installation
Conclusion: Issue is consistent and reproducible across different environments with Dart 3.10+.
💡 Expected Behavior
The code should compile without errors, as it does with:
- freezed 2.5.7 + Dart 3.6.0 ✅
- freezed 3.x + Dart 3.6.0 ✅ (presumably)
🔧 Current Workaround
Downgrade to freezed 2.x is NOT viable because:
- freezed 2.5.7 requires
_macrosfrom SDK that doesn't exist in Dart 3.10.4 - freezed 2.x is incompatible with Dart 3.8+
- Would require downgrading entire dependency tree (Riverpod 3.x, etc.)
Temporary solution:
Replace @freezed classes with manual Dart classes until fix is available.
📎 Attachments
I can provide:
- ✅ Minimal reproducible project (available at
/tmp/freezed_test_minimal) - ✅ Generated
.freezed.dartfile for inspection - ✅ Full error logs
- ✅ Large project pubspec.yaml for context
🙏 Request
Is this a known issue with Dart 3.10.x?
If so, is there:
- An ETA for a fix?
- A recommended workaround?
- A specific Dart version to use with freezed 3.x?
This is blocking development for projects that require Dart 3.8+ (for dependencies like Riverpod 3.x, very_good_analysis 10.x, etc.).
📚 Related Issues
(Search before posting - add links to similar issues if found)
Environment Details:
$ flutter --version
Flutter 3.38.5 • channel stable
Framework • revision 1ba1d176de (2 weeks ago)
Engine • revision 49d1d44610
Tools • Dart 3.10.4 • DevTools 2.43.2
$ dart --version
Dart SDK version: 3.10.4 (stable) (Tue Nov 18 11:02:31 2025 -0800) on "linux_x64"
$ flutter pub deps | grep freezed
|-- freezed_annotation 3.1.0
`-- freezed 3.2.3
Thank you for maintaining this excellent package!