Questions tagged [flutter-freezed]
95 questions
2
votes
0 answers
How do you deal with data schema migrations while using Flutter with Firestore?
I have a model as below:
// will refer to this as ProfileV1
@freezed
class Profile with _$Profile {
// stands for anon users in firebase auth
const factory Profile.anonymous({
// stands for the id of anon users in firebase auth
required…

Eray Erdin
- 2,633
- 1
- 32
- 66
2
votes
2 answers
How to use generics with freezed sealed union objects?
I have a Flutter class that uses Freezed to create a sealed union that represents either data or an error:
@freezed
class DataOrError with _$DataOrError {
const factory DataOrError.loading() = Loading;
const factory DataOrError.data(T…

Gabe
- 5,643
- 3
- 26
- 54
2
votes
1 answer
Efficiency of copying nested objects using the freezed package (Flutter/Dart)
We've been developing a flutter project that uses nested objects, all being marked as @freezed. The overall implementation of the project highly relies on the copyWith function of the freezed package. We're therefore wondering if it is really…

RominHood
- 147
- 2
- 11
2
votes
2 answers
Dart freezed same field on all constructors
I'm trying to make a state class for my todo bloc, and I want to keep the loaded todos when I start refreshing. Is there a better way to do this, basically having a mutual field in all the constructors of the class using freezed…

Arin Faraj
- 358
- 2
- 14
2
votes
0 answers
Flutter Freeze and json_serializable to Json using Bloc
I have this BoardState I'm using the Bloc Statement management.
part of 'board_cubit.dart';
@freezed
class BoardState with _$BoardState {
const BoardState._();
const factory BoardState.loading() = _Initial;
const factory…

Millenial2020
- 2,465
- 9
- 38
- 83
2
votes
1 answer
when to implements an abstract class in freezed?
I need to understand this code, resoCoder did it on DDD Playlist. why does he implements IEntity inside freezed?
The code is:
@freezed
abstract class TodoItem with _$TodoItem implements IEntity {
const factory TodoItem({
@required UniqueId…

Mariam Albarghouti
- 409
- 5
- 22
2
votes
1 answer
when should we use freezed as sealed classes or constructor?
Which way to use freezed library with bloc ? first one as a sealed classes, the other is a constructor.
First way
abstract class HomeState with _$HomeState {
const factory HomeState.initial() = _Initial;
const factory…

Mariam Albarghouti
- 409
- 5
- 22
2
votes
1 answer
Generate fromJson code for non valid json type
I am using freezed.
My code looks like this:
import 'package:freezed_annotation/freezed_annotation.dart';
part 'key_state.freezed.dart';
part 'key_state.g.dart';
@freezed
class KeyState with _$KeyState {
factory KeyState({
CancelToken?…

user3808307
- 2,270
- 9
- 45
- 99
2
votes
1 answer
dart freezed default for empty class
@freezed
class ABCModel with _$ABCModel {
factory ABCModel({
@JsonKey(name: "id") @Default('') String id,
@JsonKey(name: "name") @Default('') String name,
}) = _ABCModel;
factory ABCModel.fromJson(Map…

FeelRightz
- 2,777
- 2
- 38
- 73
2
votes
2 answers
@freezed copyWith missing with sealed classes
In the following snippet the state.copyWith function is not available.
@freezed
class MyState with _$MyState {
@JsonSerializable(fieldRename: FieldRename.snake, explicitToJson: true)
const factory MyState({@Default(0) int counter,}) = _MyState;
…

ptheofan
- 2,150
- 3
- 23
- 36
1
vote
2 answers
How to serialize all fields in Dart enhanced enums?
I am using Flutter Freezed package which in turn uses Dart json_serialize package.
I have this Dart enhanced enum with 2 fields:
enum WorkingMode {
mix(type: 1, name: "mix"),
parallel(type: 2, name: "parallel"),
sequential(type: 3, name:…

rocotocloc
- 418
- 6
- 19
1
vote
1 answer
Dose Flutter Freezed have toMap() method ? if not how I can add?
In this model when i use freezed i'm missing toMap() method
I want change the company object into Map
class Company {
final String? id;
final String? name;
Company({
this.id,
this.name,
});
Map…

Nashaf
- 23
- 7
1
vote
1 answer
Does the "equal" property in flutter freezed replace the need of Equatable?
The documentation:
Whether to generate a ==/hashcode or not
If null, picks up the default values from the project's build.yaml.
If that value is null too, generates a ==/hashcode only if the class
does not have a custom ==
Does this replace the…

Joel Broström
- 3,530
- 1
- 34
- 61
1
vote
1 answer
Flutter+Freezed: Issue when trying to create fromJson of class that contains an abstract class
Im working with Freezed in flutter/dart and I want to generete a fromJson/toJson in a freezed class that has an abstract class as a parameter, but I get an error with the abstract class.
Here is the abstract class:
abstract class IModel{
String…

BrML
- 35
- 6
1
vote
1 answer
Merge different states with Riverpod and Freezed
I have a page that needs two different API calls.
I am applying the clean architecture to write the code and Riverpod as State Management. Then I am using the Freezed package to map the different states.
How can I combine the different states?
What…

patana93
- 73
- 1
- 8