hive icon indicating copy to clipboard operation
hive copied to clipboard

Is there a way to use the map type adapter on a nested class using toJson?

Open joshpetit opened this issue 1 year ago • 0 comments

For example, if we were to have a class such as:

class Dog {
  String name;
  Trait trait  
}

class Trait {
  String traitName;
  TraitAction action;
  Map<String, dynamic> toJson() => ....
  Trait.fromJson(...);
}

Would it be possible to create a type adapter for Dog that converts the nested trait object into json rather than having to create a new type adapter for the trait class?

joshpetit avatar Jan 19 '24 14:01 joshpetit