Freezed: Error with generated code, can not find class DiagnosticableTreeMixin

Created on 16 Mar 2020  Â·  3Comments  Â·  Source: rrousselGit/freezed

So I have a bloc, with two freezed classes (state and event)

The generated code is showing a dart analysis error

Undefined class 'DiagnosticableTreeMixin'.

part of 'login_bloc.dart';

@freezed
abstract class LoginEvent with _$LoginEvent {
  const factory LoginEvent.toggleLogin() = ToggleLogin;
  const factory LoginEvent.submit() = Submit;
}

part of 'login_bloc.dart';

and

@freezed
abstract class LoginState with _$LoginState {
  const factory LoginState.login(TextEditingController email, TextEditingController password, String error) = Login;
  const factory LoginState.register(TextEditingController email, TextEditingController password, TextEditingController confirmPassword, String error) = Register;
  const factory LoginState.waiting() = Waiting;
  const factory LoginState.successful() = Successful;
}

Most helpful comment

yup that worked!

For anyone coming at this later

the import is actually

import 'package:flutter/foundation.dart';

All 3 comments

It sounds like your file has access to Flutter.
Therefore you should add:

import 'package:flutter/foundations.dart';

This will generate a bunch of things to make the object readable in Flutter's devtool.

yup that worked!

For anyone coming at this later

the import is actually

import 'package:flutter/foundation.dart';

Can we get an error in the console? I had no idea I needed to manually import foundations.

Was this page helpful?
0 / 5 - 0 ratings