Questions tagged [freezed]

148 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
0 answers

Problem with freezed / build_runner in plain dart package: "dart run" command not available

I am trying to use the freezed package inside a plain dart package - NO flutter! I am following the instructions at https://pub.dev/packages/freezed#run-the-generator . My pubspec.yaml: ... version: 1.0.0 # homepage:…
Michael
  • 181
  • 2
  • 3
0
votes
3 answers

Stop Freezed from generating toJson

According to the Freezed documentation: However, I'm using => in my code as follows: factory ProductLineDTO.fromJson(Map json) => _$ProductLineDTOFromJson(json['node']); Yet I get the toJson which I don't need. Any idea how…
Eibo
  • 245
  • 2
  • 14
0
votes
1 answer

Union class with template type

I'm trying to build a union type for api responses. I found freezed package supports union types and I tried out without issues. But as the api return different classes (responses) I think using a template type is suitable to keep the class as…
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…
0
votes
1 answer

fixedLengthList - freezed & dart

How to make fixedLengthList in class model using @freezed? @freezed class Example with _$Example { factory Example({ List example, // this list should be max 5 positions, not more }) = _Example; }
0
votes
0 answers

Error on assignable field in ObjectBox model based on a freezed class in Flutter

I'm trying to use ObjectBox on flutter with theese three Freezed classes: product_otodb.dart: import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:objectbox/objectbox.dart'; import…
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 use freezed on a class with custome function that inherits from a non-sealed class in dart?

I have just started learning freezed. I have a GameBase class below: import 'package:json_annotation/json_annotation.dart'; part 'game_base.g.dart'; @JsonSerializable() class GameBase { final int id; final String facilityName; final…
Kimiya Zargari
  • 324
  • 1
  • 14
0
votes
2 answers

Flutter - How to compare two objects while using freezed with custom jsonkey

I've created a custom class that implements freezed, and I'm trying to compare a saved Settings Object with a current one and when I compare both objects with the same values it returns it's not the same The problem is because of the dateFormat,…
cgutierr
  • 133
  • 1
  • 10
0
votes
1 answer

Cubit state shows 2 different values

I have basic auth cubit like this: class AuthCubit extends Cubit { AuthCubit() : super(const _AuthState(isUserSignedIn: false)) { FirebaseAuth.instance.authStateChanges().listen((User? user) { if (user == null) { …
alperefesahin
  • 604
  • 6
  • 22
0
votes
1 answer

Flutter - Unhandled Exception: Unhandled error type 'int' is not a subtype of type 'DateTime?'

I am using Freezed and json_annotation to serialize API objects. @freezed class Block with _$Block { const factory Order({ @JsonKey(name: 'block_id') required String id, @JsonKey(name: 'sent_at') DateTime? sentAt, @JsonKey(name:…
Ahmed Bassiouny
  • 275
  • 6
  • 26
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…
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…
0
votes
1 answer

creating initial state of radio group using bloc and freezed libraries

I am using bloc with freezed libraries. i need when the user open the app the first radio button is chosen. i have been created an observer bloc which tolled me that the initial state and the initial event have been invoked, but when i print …
1 2 3
9
10