You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I came across several examples in the Freezed documentation that do not work as expected, likely due to changes in Freezed's generated code. These examples either cause constructor errors, missing required arguments, or improper subclass behavior
I believe these examples need to be updated or clarified to match the latest Freezed version.
Steps to Reproduce
Here are some examples from the documentation that fail and the errors they produce:
Example 1: Non-empty private constructor (Response example)
@freezed
sealed class Response<T> with _$Response<T> {
// We give "time" parameters a non-constant default
Response._({DateTime? time}) : time = time ?? DateTime.now();
// Constructors may enable passing parameters to ._();
factory Response.data(T value, {DateTime? time}) = ResponseData;
// If ._ parameters are named and optional, factory constructors are not required to specify it
factory Response.error(Object error) = ResponseError;
@override
final DateTime time;
}
Error:
1 positional argument expected by '_', but 0 found.
Try adding the missing argument.
Example 2: MyFreezedClass
class Subclass {
Subclass.name(this.value);
final int value;
}
@freezed
class MyFreezedClass extends Subclass with _$MyFreezedClass {
// We can receive parameters in this constructor, which we can use with `super.field`
MyFreezedClass._(super.value) : super.name();
factory MyFreezedClass(int value /* other fields */) = _MyFreezedClass;
}
I came across several examples in the Freezed documentation that do not work as expected, likely due to changes in Freezed's generated code. These examples either cause constructor errors, missing required arguments, or improper subclass behavior
I believe these examples need to be updated or clarified to match the latest Freezed version.
Steps to Reproduce
Here are some examples from the documentation that fail and the errors they produce:
Example 1: Non-empty private constructor (Response example)
Error:
Example 2: MyFreezedClass
Code generation just doesn't work at all
Environment
Freezed Version: 3.0.2 and 2.5.8
Dart Version: 3.7.0
Flutter Version: 3.29.0
The text was updated successfully, but these errors were encountered: