json_serializable.dart icon indicating copy to clipboard operation
json_serializable.dart copied to clipboard

how to handle dynamic type map or array

Open naumanahmed19 opened this issue 1 year ago • 1 comments

I have a scenario where data could be a dynamic map with values or an empty array, is there any annotation method to check null or isEmpty.

class myModel{
  final Attr? attrs; 
}

right now json['attrs'].isEmpty this works but i lose changes when i run build runner again.


  attrs: json['attrs'] == null || json['attrs'].isEmpty
          ? null

naumanahmed19 avatar Jul 11 '22 21:07 naumanahmed19

What type is Attr?

kevmoo avatar Jul 22 '22 18:07 kevmoo