toJson method Null safety

Map<String, dynamic> toJson()

Implementation

Map<String, dynamic> toJson() => {
      "id": id,
      "title": title,
      "resultsCount": resultsCount,
      "children": children == null
          ? null
          : List<dynamic>.from(children!.map((x) => x.toJson())),
      "hexaCode": hexaCode,
    };