Questions tagged [freezed]

148 questions
4
votes
0 answers

The name '_SignInFormState' isn't a type and can't be used in a redirected constructor. Try redirecting to a different constructor. flutter

I am new to bloc. My error is "The name '_SignInFormState' isn't a type and can't be used in a redirected constructor. Try redirecting to a different constructor. flutter."I generated freezer files. The issue still persists. part of…
Abin Sunny
  • 89
  • 1
  • 7
4
votes
3 answers

Unable to generate classname.g.dart class using freezed package

I have a freezed class that looks like this: @freezed abstract class GiftGiver with _$GiftGiver { const factory GiftGiver({ String? id, String? uid, String? imageUrl, String? giftDetails, String? listingDate, @Default(5)…
4
votes
1 answer

Flutter Freezed, Unknown/Fallback union value

Is it possible to use a FallBack/Unknown union contructor in freezed? Lets say I have this union: @Freezed(unionKey: 'type') @freezed abstract class Vehicle with _$Vehicle { const factory Vehicle() = Unknown; const factory Vehicle.car({int…
4
votes
1 answer

Freezed package flutter throwing non-nullable error in code generation

I am starting a project and decided to use the new version version of **Freezed** for my models, but when I run flutter *pub run build_runner build* to generate my code I get the following error: >The parameter 'placeFormattedAddress' of 'Address'…
sempernoob
  • 186
  • 2
  • 8
3
votes
1 answer

Best way to have a const factory for empty instance in Flutter's freezed

I am trying to figure out the best way to implement a constant factory for "empty" instance of the defined model while keeping its original constructor strict (require all arguments without defaults). The closest solution I could get is using Union…
Roman Shirokov
  • 329
  • 4
  • 12
3
votes
2 answers

Writing abstract classes while using Freezed

I can't seem to understand how to make abstract classes and their subclasses work properly with Freezed. Specifically, I need to define an abstract super-class with some to-override getters; the subclasses will need to override the getters, while…
venir
  • 1,809
  • 7
  • 19
3
votes
3 answers

Freezed & json_serializable handling parsing error

I'm looking for a general solution for handling parsing errors of complex (nested + fields of Any type) objects using Freezed and json_serializable. It should use the default value in case a field can't be parsed, and not compromise the whole…
deniskrr
  • 952
  • 1
  • 6
  • 12
3
votes
3 answers

Flutter Freezed Method not found

I'm using Freezed to generate data-class on my flutter project. I did everything exactly like mentioned in the package readme: import 'package:freezed_annotation/freezed_annotation.dart'; part 'access_token.freezed.dart'; @freezed class…
genericUser
  • 4,417
  • 1
  • 28
  • 73
3
votes
1 answer

Freezed @Default list parameter creates unmodifiable list

I am trying out the example given in the Freezed page at https://pub.dev/packages/freezed. This is the example I am testing replacing int with List adding a [40] as default. @Freezed(makeCollectionsUnmodifiable: false) class Example with…
Polymath
  • 630
  • 7
  • 11
3
votes
0 answers

How to map nested freezed union classes to drift/moor sql tables?

I need to save this Objects into a SQL/Drift DB, how can/should I design die Tables/Rows for an efficient mapping? Here is are examples of a (deep)nested union class. It itself is a union class and also has a field which in itself is also a union…
Soyellow
  • 144
  • 9
3
votes
2 answers

Unable to generate fromJson() and toJson() for generics using freezed package

We are trying to create a generic Category class. At the time being, we are unsure whether category will have integer or UUID as key. Hence, we need the id to be generic for now. All works fine. However, we are unable to generate the fromJson() and…
Ariel
  • 2,471
  • 1
  • 26
  • 43
3
votes
1 answer

Could not generate `fromJson` code for `images` because of type `Asset`

I am using freezed with json generator. i am facing this error on generating the code. Could not generate fromJson code for images because of type Asset. The Code Is: abstract class ProductDTO with _$ProductDTO { factory ProductDTO({ …
user16906111
3
votes
1 answer

Custom json converter with freezed without a wrapper class

I'm using the freezed package to work with immutable models and make use of the built-in feature for json serialization by the json_serializable package. I have a simple User class/model with different union types (UserLoggedIn, UserGeneral,…
kounex
  • 1,555
  • 4
  • 12
3
votes
0 answers

Failed to build build_runner:build_runner:

I'm trying to run flutter packages pub run build_runner build --delete-conflicting-outputs to generate freezed files but I'm getting this error. Failed to build…
Bhawna Saroha
  • 603
  • 1
  • 11
  • 28
3
votes
1 answer

flutter freezed : equals type of object is not same

I am using freezed to make object from json : @freezed class UserMessagesResponseModel with _$UserMessagesResponseModel { const factory UserMessagesResponseModel({ final Data? data, }) = _UserMessagesResponseModel; factory…
Cyrus the Great
  • 5,145
  • 5
  • 68
  • 149
1
2
3
9 10