how to extend `Freezed` abstact classes

3.4k views Asked by At

update: edited as my original question is answered in this issue,

given an freezed class cannot directly implement other classes (see issue above)

Foo.baz can implement Baz as below

abstract class Baz<T> {
  const Baz(this.data);
  final T data;
}

@freezed
abstract class Foo<T> with _$Foo<T> {
  @Implements(Baz)
  const factory Foo.baz(T data) = _FooBaz;
}

but the Type T doesn't get passed to the implemented Baz in the

abstract class _FooBaz<T> implements Foo<T>, Baz<dynamic> { /// `<= HERE!!!!`
  const factory _FooBaz(T data) = _$_FooBaz<T>;

  T get data;
  _$FooBazCopyWith<T, _FooBaz<T>> get copyWith;
}

if I try to pass the the Type inside @Implements I get the error

Arguments of a constant creation must be constant expressions. Try making the argument a valid constant, or use 'new' to call the constructor.

screenshot

is there any way to correctly pass the type to the implemented class?

0

There are 0 answers