MatterFabric.fromJson constructor

MatterFabric.fromJson(
  1. Map<String, dynamic> dataMap
)

Creates a MatterFabric object from the JSON response to a GET request.

Implementation

factory MatterFabric.fromJson(Map<String, dynamic> dataMap) {
  // Handle entire response given with no filter.
  Map<String, dynamic> data = MiscTools.extractData(dataMap);

  return MatterFabric(
    type: ResourceType.fromString(data[ApiFields.type] ?? ""),
    id: data[ApiFields.id] ?? "",
    idV1: data[ApiFields.idV1] ?? "",
    status: data[ApiFields.status] ?? "",
    fabricData: MatterFabricData.fromJson(
        Map<String, dynamic>.from(data[ApiFields.fabricData] ?? {})),
    creationTime: DateTime.tryParse(data[ApiFields.creationTime] ?? "") ??
        DateUtils.dateOnly(DateTime.now()),
  );
}