Questions tagged [flutter-freezed]
95 questions
0
votes
1 answer
Adding methods to Freezed Class
I'm using freezed package to generate data classes.
The package support disabling the copyWith generation using @Freezed(copyWith: false) annotation.
I want to implement a custom copyWith to my Freezed data class. Here is my code:
@Freezed(copyWith:…

genericUser
- 4,417
- 1
- 28
- 73
0
votes
1 answer
Combine freezed lib with model state
I have a @freezed class defined like below and I need to be able to use its artistId in order to make an API call and get an Artist object. Since that object will be used across multiple screens and filtering functions, I don't want to make requests…

Stelios Papamichail
- 955
- 2
- 19
- 57
0
votes
2 answers
In Flutter, an object's fromJson method generated by freezed occured type cast error, DateTime -> String
I have used freezed library to manage my Remote DTO classes and Ui Models.
In this question case, my Object LifeDiagnosisResult DTO and Ui Model only have one difference - createdAt field.
When I put data, I used SharedPreference (because backend is…

Jun
- 451
- 4
- 16
0
votes
1 answer
I/flutter ( 4483): ** [Error] type 'String' is not a subtype of type 'Map' in type cast. isError: [true]
I am using Freezed for serialization. I need to get the colour from the database which is String like this "#FFFFFF".
I need when I get this string, converting it to int to as a colour.
but I get the error:
I/flutter ( 4483): ** [Error] type…

Reatching the Stars
- 73
- 1
- 1
- 5
0
votes
1 answer
Target of URI doesn't exist: 'className.freezed.dart'
I am new to flutter and after searching everywhere I couldn't find the reason behind this error
Below is my code
// ignore: file_names
import 'package:freezed_annotation/freezed_annotation.dart';
part 'NetworkResponse.freezed.dart';
@freezed
class…

Nick
- 1,127
- 2
- 15
- 40
0
votes
1 answer
How to generate toJson with return type Map using Freezed lib in Flutter?
I want to generate toJson() method with return type Map
How can I do that?

Tushar Asodariya
- 629
- 2
- 7
- 20
0
votes
0 answers
Unable to install Freezed with flutter because freezed depends on freezed?
I want to try the Freezed package with flutter, I follow the setup steps in the package readme and this video.
But when I enter the command to add the freezed package;
flutter pub add --dev freezed
, got the following error message :
Because…

Constant Dupuis
- 1
- 2
0
votes
1 answer
Bloc error apiState dataloading isn't a type. Try correcting the name to match an existing type ,showing error with freezed package
i am trying to learn bloc with freezed .Everything was fine in event,state & bloc but when i am trying build with blocbuilder,this error occured while implementing for every state.
**Error is : GameapiState.dataloading isn't a type.
Try correcting…

Diljith
- 69
- 8
0
votes
1 answer
How can I reference a generic object that implements JsonSerialized with freezed in dart
I'm using https://pub.dev/packages/freezed to generate data classes with json.
I want to do this, so that I can use toJson() within the class.
class DatabaseRepository { ... }
But when I define the generic, I get the…

HJo
- 1,902
- 1
- 19
- 30
0
votes
1 answer
How to mix normal model with @freezed model?
I want to create CategoryModel which has two fields categoryName and items, categoryName is a String field but items are List items and CategoryItem depends on freezed code generation while CategoryModel is not.
the following is my…

Addow
- 104
- 1
- 2
- 7
0
votes
1 answer
flutter unit testing stubbed method returns null
I,m unit testing flutter class using mockito. I stubbed one method using 'when()' but it returns null. is there something wrong in my testing?. I have used freezed union to generate Result class. My Repository is an abstract class
this is my test…

ismailfarisi
- 249
- 1
- 2
- 8
0
votes
2 answers
freezed constructor initialisers
I have model like this (simplified):
@immutable
class CountryModel {
final String name;
final String isoCode;
final String assetPath;
const CountryModel({
required this.name,
required this.isoCode,
}) : assetPath =…

Nagual
- 1,576
- 10
- 17
- 27
0
votes
1 answer
cubit state return always a null value
i am learning flutter-bloc with freezed, i am trying to retrieve a data from sqflite. i have a achieved that without bloc pattern, it worked fine. but when i use bloc to do so the return value is always null!.
This Button when is clicked it is…

Mariam Albarghouti
- 409
- 5
- 22
0
votes
1 answer
Another exception was thrown: Error: Could not find the correct Provider above this BlocSelector Widget
i am using cubit with freezd. i have an input text form field inside a bottom sheet, all thing is perfect, but once i clicked the input form field and typing any letter this exception occurs.
Another exception was thrown: Error: Could not find the…

Mariam Albarghouti
- 409
- 5
- 22
0
votes
0 answers
When I generate the archives using Freezed package I received this message: [SEVERE] freezed:freezed on [my archive directory]: Stack Overflow
I'm using different packages what uses the freezed generator, including modular with modular_codegen, when I generate the file's running the archives generator command, I receive this message
[SEVERE] freezed:freezed on [my archives…

Alencar Moreira
- 1
- 1