Questions tagged [flutter-freezed]
95 questions
1
vote
1 answer
Flutter freezed convert List to json
this is my two freezed class which i want to make a simple json from ContactsData
@freezed
class ContactsData with _$ContactsData {
const factory ContactsData({
String? displayName,
String? givenName,
String? familyName,
String?…

DolDurma
- 15,753
- 51
- 198
- 377
1
vote
0 answers
define common fields once in dart freezed union classes
The freezed docs mention being able to define shared properties for union types, but the examples given show all of the properties being redefined for each type. Is there an easy way to only have to define all of the common properties just once?

anqit
- 780
- 3
- 12
1
vote
0 answers
Disable copyWith for a nested Freezed Object
I'm using the Freezed package to create Objects. I want to disable the copyWith of a nested @Freezed Object. See the following example:
@freezed
class RenewLeaseState with _$RenewLeaseState {
const factory RenewLeaseState({
…

genericUser
- 4,417
- 1
- 28
- 73
1
vote
1 answer
Deserialising using Freezed with Generic Type Class
Feature for deserializing Generic Classes was introduced to freeze a few months back.
I am trying to follow the documentation, but I am facing a compile time error:
The argument type 'NameOfClass Function(Map)' can't be assigned to…

Michael Hathi
- 1,933
- 2
- 17
- 27
1
vote
2 answers
The event I am dispatching is not called in the Bloc
I am new to the Bloc Pattern in Flutter. I started using it in combination with the freezed package. But my event is not called from within the Bloc (or not dispatched at all)
Following is what I have,
State
part of…

SomeWiredProgrammer
- 11
- 1
1
vote
0 answers
Is there a way to ignore toJson for a field based on other fields in freezed class?
I managed to ignore fields adding includeIfNull: false and toJson: ignore writing ignore function as T? ignore(dynamic _) => null;.
What I want to achieve is to include field "id" only if "variants" is an empty array, otherwise include its…

Alex Tarana
- 11
- 2
1
vote
1 answer
How to use copyWith on a freezed union class, that implements a specific mixin
Lets say I have this class from the documentation :
abstract class GeographicArea {
int get population;
String get name;
}
@freezed
class Example with _$Example {
const factory Example.person(String name, int age) = Person;
…

Christian
- 834
- 7
- 18
1
vote
0 answers
Flutter bloc accessing the previous state?
I'm confused why yielding a new state is not causing the state variable inside by bloc class to actually update. The value of state remains what I initialize it to despite mapping events to to functions that are yielding new states. For example if…

user2561417
- 295
- 4
- 13
1
vote
1 answer
Flutter @Freezed() vs @freezed annotation
What are the differences between @Freezed() and @freezed annotations ?
In official freezed documentation the @freezed annotation used.
But there are some tutorials like this Medium post where @Freezed() annotation used instead.
I tried both and in…

Nerower
- 193
- 12
1
vote
2 answers
Using Flutter Freezed to generate code to parse a Json Object
I'm trying to parse some JSON from a file and decided to use Freezed to generate the code. The problem is that (as far as i can tell) there's no way to use a JSON object's name.
So say I have the following JSON object:
{
"uniqueName":{
…

Exodos
- 33
- 1
- 6
1
vote
0 answers
Nested freezed class cannot access parameter [Flutter, Freezed]
I have a bizarre issue. I am trying to generate models with a freezed package. I have nested two classes that connected each other with different key values.
This is the main class that I will use. Parameters come from data key.
@freezed
class…

Kaan Taha Köken
- 933
- 3
- 17
- 37
1
vote
1 answer
Transform Freezed Events in BLoC
I'd like to know if there's a way to properly set BLoC Events using Freezed library. Problem appears when you want to add transformer into selected events.
Let's consider this scenario:
class CustomState {}
@freezed
class CustomEvent with…

Pjoter
- 13
- 3
1
vote
0 answers
How to accept a data of different data type in flutter model class created using freezed?
I have a custom model class for Timestamp in which I have a constructor which accepts the object of DateTime and instantiates the Timestamp data.
How do I convert this class to use freezed?
class Timestamp {
const Timestamp({
required date,
…

Abhimanyu
- 11,351
- 7
- 51
- 121
1
vote
0 answers
How I can extend a class that use a mixin to another class that are using mixin in flutter?
I have a class that has a mixin generated through freezed.
I have another class that has a mixin generated through freezed.
I want to extend the second class, but I receive a type error because the mixin methods have differences.
Example:
class A…

donoaga
- 11
- 2
1
vote
2 answers
Freezed copyWith method not avaliable for List model in Union/Sealed? (using Flutter with Freezed package)
How can I get my code (Flutter using Freezed) to obtain use of the "copyWith" freezed feature for updating state here?
Freezed Class:
import 'package:flutter/foundation.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part…

Greg
- 34,042
- 79
- 253
- 454