Questions tagged [flutter-freezed]

95 questions
1
vote
1 answer

Flutter failed to build build_runner with Freezed

I am facing this issue when I added a new property to the Freezed class for the first time in three months, and then run flutter clean && flutter pub get && flutter pub run build_runner build --delete-conflicting-outputs. And I tried the answers on…
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…
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…
1
vote
0 answers

What's the best approach to model with freezed's Union/Sealed Classes JSON serialiation when you can't control the structure of the provided JSON?

Given an unmodifiable JSON you get from the server like this: { "name": "someName", "fields": [ { "name": "field1", "type": "text", "subtype": "autofill", "value": "someVal" }, { "name": "field2", "type": "text", …
Nico Rodsevich
  • 2,393
  • 2
  • 22
  • 32
1
vote
0 answers

Accessing underlying data from Freezed union classes using Riverpod

I have created these unions using Freezed: abstract class ProductState with _$ProductState { factory ProductState.loading() = ProductLoading; factory ProductState.created(Product product) = ProductCreated; } Then I have a provider providing a…
ccnrbrn
  • 126
  • 5
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
0
votes
1 answer

How to convert an object to json using freezed in flutter

I have written a freezed data class. @freezed class GithubRepoDTO with _$GithubRepoDTO { const GithubRepoDTO._(); const factory GithubRepoDTO({ required UserDTO owner, required String name, @JsonKey(fromJson: _fromJson) required…
0
votes
1 answer

Flutter freezed - what is @JsonValue for

I see you can do, for example factory User({ @JsonKey(name: 'home_address') String? homeAddress, @JsonKey(name: 'first_name') String firstName, }) and the keys home_address and first_name from a json will be the properties homeAddress and…
user3808307
  • 2,270
  • 9
  • 45
  • 99
0
votes
1 answer

Bloc+Freezed, How to split Event class

class BookingInfoEvent with _$BookingInfoEvent { // another (const factory) events ... const factory BookingInfoEvent._search({required int mid}) = _Search; } class _BookingInfoSearch with _$_BookingInfoSearch { const factory…
Get Malone
  • 29
  • 2
0
votes
1 answer

How to fetch two json Value via one field in freezed?

Suppose I have a model class in freezed, @freezed abstract class Dto implements _$Dto { const factory Dto({ String? name, String? url, }) = _Dto; factory Dto.fromJson(Map json) => _$DtoFromJson(json); } Now,…
0
votes
1 answer

Unable to access fromJson function for freezed custom model

I have declared a custom freezed model in a flutter web project as follows: @freezed class User with _$User { const factory User({ required int id, required String name, required Address address, @Default(null) Contact? contact, …
0
votes
1 answer

How to conect entity(domain layer) and model(data layer) using BloC+Freezed

I'm trying to learn how to follow a clean feature-first architecture using Bloc and Freezed. From what I've seen, I should have inside the Domain layer, an entity class declaring only its properties for the presentation layer to use, and in the Data…
BrML
  • 35
  • 6
0
votes
1 answer

return Future.value is null in Freezed .when method

I am using Freezed package to create NetworkResponse class to use with Networking manager. I return Future.value(cartFetched) in getCartData method and access it in fetchCart but value in Future.then method is always null. If I change the…
hemant
  • 1,771
  • 4
  • 31
  • 43
0
votes
1 answer

Depending on a non-published plugin with freezed generated files

In my project, I am using the flutter_google_places_sdk but I needed to modify certain things in its interface, so I forked the repository in Github, and I added a dependency override in my pubspec.yaml to point to my own Github repository for this…
Sebastien
  • 3,583
  • 4
  • 43
  • 82