json-serializable Questions

4

I have a freezed class that takes an enum in its constructor, but when trying to perform the jsonEncode method on this class, it fails with the following error: The following JsonUnsupportedObjectE...

2

My app was running ok but after pub upgrade --major-versions I am getting problems on all models. Example model: import 'package:app_220/models/Leads/LeadFieldModel.dart'; import 'package:flutter/f...
Major asked 29/10, 2021 at 19:2

3

Solved

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. Ho...
Surly asked 4/3, 2022 at 6:45

1

I am trying to use a single model for both storing the data locally using Isar, and also for using with Retrofit for REST API requests. But Isar requires all the Linked classes to be defined with t...
Cacodemon asked 14/10, 2022 at 18:6

3

I am using json_serializable in Flutter to store a class in a file and read back from it. I am not posting the original class here for simplicity, but the principle is that half way through writing...
Upcoming asked 8/12, 2021 at 14:36

4

Solved

json_serializable plugin of Dart, does a great job of automatically generating some error prone and cumbersome parts of code, in exchange for some boilerplate: two methods, one annotation, and one ...

2

Solved

I am trying to create a build_extensions rule in build.yaml for builders freezed and json_serializable to output all generated models in the directory lib/generated/model, irrespective of their ori...
Estheresthesia asked 22/12, 2022 at 13:58

1

Solved

I've tried to create a profile model like this; fromJson looks good, but I have a problem with toJson: @Freezed( fromJson: true, toJson: true, map: FreezedMapOptions.none, when: FreezedWhenOpti...

2

Suppose there are two models User and City @JsonSerializable() class User { int id; String name; City? city; List<Map<String, City>>? listMapCity; } @JsonSerializable() class City...
Milissa asked 23/5, 2021 at 10:2

2

Solved

I'm using a private constructor in my class, but the code generation fails with The class Foo has no default constructor. I'm using latest json_serializable: version i.e. 6.1.5: @JsonSerializable...
Peso asked 28/3, 2022 at 12:11

1

Solved

I have a class which I am trying to use with Freezed, Json Serializable, and Hive. After running dart run build_runner build and generating the necessary classes, my compiler gives me the following...
Avilla asked 17/3, 2022 at 16:10

1

I have a dart object that includes a field of type Money, which itself is composed of amount and currency: @JsonSerializable() class Account { final String id; final String type; final String s...
Twittery asked 20/12, 2021 at 18:41

1

I just started to learn Flutter. I use vscode as editor I need to use json_serializable on my code. I read https://pub.dev/packages/json_serializable and make my build.yaml just like what show ther...
Alesandrini asked 12/11, 2021 at 2:44

3

I'm trying to implement toJson/fromJson for a union generated by the freezed package. Let's say we have a class as following: @freezed abstract class Result with _$Result { const factory Result.e...
Mucky asked 17/6, 2020 at 20:27

1

I created two model classes with freezed. One class is having parameter of other class inside it. The problem started when I try to send data to firestore. This following error appears. E/flutter (...

2

Solved

I want to add a custom converter to a freezed class like in this answer. I tried it with this code: @freezed class NewsPost with _$NewsPost { factory NewsPost({ @JsonKey(name: "date") @...
Complementary asked 18/4, 2021 at 16:12

0

I am trying to follow the Clean Architecture via this YouTube tutorial and because of that I have a set of models objects in the data layer that extends the entities objects. Since I have many mode...
Veracruz asked 17/10, 2021 at 12:9

2

Solved

How do I make a Freezed object take a generic type? I want to do this: import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:vepo/src/entity_types/option_entity.dart'; part ...
Retinue asked 6/6, 2021 at 6:59
1

© 2022 - 2025 — McMap. All rights reserved.