Questions tagged [freezed]
148 questions
1
vote
1 answer
Dart & Freezed - not generating file
I have freezed_classes.dart :
import 'package:meta/meta.dart';
import 'package:freezed/builder.dart';
part 'freezed_classes.freezed.dart';
@immutable
abstract class User with _$User {
const factory User(int id, String firstName, String lastName,…

Norbert Prośniak
- 13
- 1
- 3
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
1 answer
Pass Freezed Constructor Tear-Off to Generic Widget
What the title says. I have a freezed constructor tear-off that I'm trying to pass to a Widget and it's not returning null, and I'm trying to figure out what I'm doing wrong. Here is the freezed class:
@freezed
class PatientField with…

Grey
- 331
- 3
- 11
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
UI Not updating on bloc state change
I am new in using bloc library with freezed package. I have a scenario where a list of objects is coming from API is displayed. Now the list tile has a Marked as Fav button and clicking upon it a event is trigged and fav bool is toggled and state is…

Biswajit Kumar Paul
- 23
- 1
- 6
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 to extend freezed sealed class of another?
I have many states in my app, but many of them contain 4 same States :
Idle
Loading
Success
Error
I'm using Freezed library to create my states. It forces me to create a lot of boilerplate code, because I have to add 4 additional constructors in…

Sergey Shustikov
- 15,377
- 12
- 67
- 119
1
vote
0 answers
Flutter @freezed Could not generate `toJson` code error
After defining some response data structure i'm trying to build @freezed class, but i get this error:
Could not generate `toJson` code for `medias` because of type `Media`.
after some of research about this problem i can't found how can i resolve…

DolDurma
- 15,753
- 51
- 198
- 377
1
vote
1 answer
How to define relations inside @freezed entity with objectbox dart?
By following this
I have a CurrentUser entity as follows:
import 'package:admin/core/auth/enums/content_type.dart';
import 'package:admin/core/permission/model/permission.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import…

Michael
- 13
- 1
- 5
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
1
vote
0 answers
Flutter Freezed - Union types and "copyWith"
I have this union:
@freezed
abstract class VeganItem extends VeganItemAbstraction with _$VeganItem {
@With(GroceryItemMixin)
const factory VeganItem.groceryItem(
{int? id,
String? name,
String? companyName,
String?…

BeniaminoBaggins
- 11,202
- 41
- 152
- 287
1
vote
0 answers
handling float action button with bloc
i am created a bottom sheet on click the float action button, which doing two functions.
1- bottom sheet popup.
2- if the form of bottom sheet is valid when clicked will save data to database.
i am using bloc with freezed. is when i click the float…

Mariam Albarghouti
- 409
- 5
- 22
1
vote
1 answer
bottom sheet is showing repeatedly once event triggred using bloc
I am a newbie, learning how to use bloc with freezed. i created a bottom sheet when the user click to the float action button, the bottom sheet appears. Bottom sheet contains text field and three radio groups when i click to select a radio the…

Mariam Albarghouti
- 409
- 5
- 22
1
vote
1 answer
How to corect toJson converter in freezed lib for dart/flutter
When trying to convert, the Profile class is not converted correctly. Exited as the result of the toString () function.
Person.dart
import 'package:adminapp/domains/Test/Profile.dart';
import…

Yerbol Kistaubayev
- 27
- 1
- 6
1
vote
0 answers
Flutter Freezed/json_serializable - runtimeType is missing from generated json
For some reason the runtimeType is missing in the generated json of this Freezed class. It only happens sometimes. See image below:
This causes the switch case in the image to fall through to throw FallThroughError();, since runtimeType doesn't…

BeniaminoBaggins
- 11,202
- 41
- 152
- 287