Questions tagged [freezed]
148 questions
1
vote
1 answer
Flutter Freezed Pakcage Sealed Classes Methods
When I generate sealed classes with Freezed, How can I add methods to the sealed classes?
For example:
import 'package:freezed_annotation/freezed_annotation.dart';
part 'student_state.freezed.dart';
@freezed
abstract class StudentState with…

Yair Chen
- 917
- 6
- 10
1
vote
0 answers
Can't (de)serialize nested generic classes with Dart freezed and json_serializable
I got a class First defined as:
@freezed
class First with _$First {
@JsonSerializable(explicitToJson: true)
factory First({
required String a,
@BConverter() required T b,
}) = _First;
factory First.fromJson(Map

Nik.Circles
- 51
- 5
1
vote
3 answers
Validating freezed model classes
I am looking for a good way to validate freezed models. So far I came up with three approaches, which are shown in the snippet below.
@freezed
class Options with _$Options {
Options._();
factory Options._internal({required List…

kevlatus
- 330
- 1
- 8
1
vote
1 answer
Flutter Dart - Firestore doc with nested maps to data class with freezed
In Firestore my documents are structured like this:
In this example the map lineup has two children of type map. There might be more and there might be zero for other docs.
I'm trying to convert the lineup map of a DocumentSnapshot into a LineUp…

Lara
- 84
- 1
- 7
- 30
1
vote
2 answers
Create interface that contains Freezed class signatures so I can called freezed functions on my interfaces
I'm trying to have a base Freezed interface which my app entity interfaces can extend so I can call the freezed functions on the interfaces. I've started the process here which seems to be working so far:
abstract class IUserRegistrationEntity…

BeniaminoBaggins
- 11,202
- 41
- 152
- 287
0
votes
1 answer
Validating Json in Dart JsonSerializable and Freezed
I'm using Freezed to create data classes, and to de-serialized them from a json (with the integration with JsonSerializable).
But sometimes the json are incomplete, and the fromJson method do not validate the json. So it throws a _TypeError error…

perojas3
- 35
- 5
0
votes
1 answer
I want to set an enum as a property of 'freezed' and use an extended getter, but I cannot use it
I have set an object created as an enum to a property of an immutable object created with 'freezed'. Additionally, I have created an object that extends the enum object. While I expected it to work without any issues, I cannot use the switch I…

sub
- 117
- 1
- 6
0
votes
1 answer
Regarding the one line added to the immutable class using freezed, I have a question
I have code like this:
import 'package:freezed_annotation/freezed_annotation.dart';
part 'token_state.freezed.dart';
@freezed
class TokenState with _$TokenState {
const factory TokenState({
required String token,
}) = _TokenState;
}
What…

sub
- 117
- 1
- 6
0
votes
1 answer
Flutter "type 'Null' is not a subtype of type 'Map' in type cast"
I am creating an app to track the results of soccer matches with external API. I created model providing live match properties which you can see below:
import 'package:freezed_annotation/freezed_annotation.dart';
part…

Kresh
- 1
- 3
0
votes
2 answers
How to use late final keyword in Flutter Dart freezed model?
How to use late final keyword in Flutter Dart freezed model ?
This code generates successfully and has no static analysis error but it does not compile strangely.
import 'dart:convert';
import…

TSR
- 17,242
- 27
- 93
- 197
0
votes
1 answer
How to add a separate thread in Python to avoid delays in the app?
I am developing a very simple game in Python.
In the game, when player hits the bouncing ball, I call a function named sayThis() that sends a GET or POST to a remote API located in my computer like below:
def sayThis(param):
try:
…

emsiloader
- 75
- 7
0
votes
1 answer
How to fetch two json Value via one field in freezed?
Suppose I have a model class in freezed,
@freezed
abstract class Dto implements _$Dto {
const factory Dto({
String? name,
String? url,
}) = _Dto;
factory Dto.fromJson(Map json) =>
_$DtoFromJson(json);
}
Now,…

Meshkat Shadik
- 194
- 7
0
votes
1 answer
Context: Field isn't final, but constructor is 'const'
I want to create quiz class with mutable variable.
So I use @unfreezed and this class also have json serializable.
so I have an error: Context: Field isn't final, but constructor is 'const'.
Because @unfreezed gen non final field, so auto generate…

Kiều Phong
- 21
- 2
0
votes
1 answer
How to conect entity(domain layer) and model(data layer) using BloC+Freezed
I'm trying to learn how to follow a clean feature-first architecture using Bloc and Freezed.
From what I've seen, I should have inside the Domain layer, an entity class declaring only its properties for the presentation layer to use, and in the Data…

BrML
- 35
- 6
0
votes
1 answer
When I use Flutter Freezed, can I parse more than one jsonData in the same layer into a model?
Here's one jsonData.
{
'name' :'chris',
'age' : 52,
'gender' : M,
'hobby' :'piano',
'favoriteFood' :'burger'
}
Here are two Freezed models
@freezed
class DefaultModel with _$DefaultModel{
const factory DefaultModel({
required String name,
…

seokseok
- 21
- 2