Questions tagged [freezed]

148 questions
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

How should I manage data classes of various subtypes?

This is my problem, imagine you need to show a table of clients, there you only need to show about 4 fields of the data class Client: Name Last Name Birthday Id But when I go to the details of a client I need to see a the fields above and some…
1
vote
2 answers

Using comparable on @freezed annotated class is causing compile time error

I have to sort items of a class created with @freezed annotation. I have added Comparable interface to the signature. It is causing following compile time exception: Error (Xcode): lib/models/app_language.freezed.dart:143:7: Error: The non-abstract…
Rahul
  • 3,529
  • 1
  • 5
  • 19
1
vote
1 answer

getting error when adding json_serializable

I added json serializabe in my pubspec.yaml and getting below error : Bad state: Could not parse the options provided for json_serializable. Unrecognized keys: [super-parameters, enhanced-enums]; supported keys: [any_map, checked, constructor,…
1
vote
1 answer

Error on auto generated freezed code while extending another class. Is there a better way to do it?

@freezed class ProductModel extends ProductEntity with _$ProductModel { // ignore: invalid_annotation_target @JsonSerializable(fieldRename: FieldRename.snake, explicitToJson: true) const factory ProductModel( int id, String…
1
vote
0 answers

Emit was called after an event handler completed normally [Flutter]

Exception is thrown on second call 'emit' inside 'firstEvent' case. I know why, but I dont know how to make it work. Problem exists when I use event.map. _AssertionError emit was called after an event handler completed normally. This is usually due…
Piotr Temp
  • 385
  • 5
  • 12
1
vote
0 answers

Custom JsonConverter with different types in toJson and fromJson

In order to read from and write data with relations to the PocketBase API I need custom fromJson and toJson methods to de/serialize it to my models: @freezed class MyModel with _$MyModel { const factory MyModel({ String name, …
TomTom101
  • 6,581
  • 2
  • 20
  • 31
1
vote
1 answer

Flutter Bloc + Socket.io + Freezed implementation

How to implement socket_io_client to flutter_bloc with freezed?
Paul Grei
  • 369
  • 2
  • 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
3 answers

Renaming Flutter Freezed field names to snake, pascal,kebab or anothing along those lines

Posting this question to answer it myself. Hope this helps someone. The problem: Generating code with flutter freezed but changing the to and from json field names to a specific renaming pattern.
Mu'aaz Joosuf
  • 103
  • 1
  • 9
1
vote
1 answer

How to Test a StateNotifiers reaction to a Stream?

My Setup I have a StateNotifier whose state is a @freezed class: @freezed class MyFreezedState with _$MyFreezedState{ const factory MyFreezedState({ required AsyncValue asyncFreezedStateInt, }) = MyFreezedState; } class MyStateNotifier…
Christian
  • 834
  • 7
  • 18
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