fromJson property
Whether to generate a fromJson
or not
If null, picks up the default values from the project's build.yaml
.
If that value is null too, will be inferred based on whether the Freezed
class has a fromJson
constructor`, such that
@freezed
class Example with _$Example {
factory Example(int a) = _Example;
factory Example.fromJson(Map<String, Object?> json) => _$ExampleFromJson(json);
}
generates a fromJson
.
On the other hand, changing fromJson(Map json) => _$ExampleFromJson(json)
to no-longer use =>
and instead use { return }
will disable the
generation of fromJson
,
@freezed
class Example with _$Example {
factory Example(int a) = _Example;
factory Example.fromJson(Map<String, Object?> json) {
// Will not generate a _$ExampleFromJson class as we are using `{ return }`
return {...};
}
}
Implementation
final bool? fromJson;