getList static method

List<DashboardItem> getList(
  1. Map<String, dynamic>? json
)

Implementation

static List<DashboardItem> getList(Map<String, dynamic>? json) {
  List<DashboardItem> list = [];

  if (json != null &&
      json.runtimeType != Null &&
      json.toString() != 'null' &&
      json.containsKey('items') &&
      json['items'] != null) {
    var data = json['items'] as List;
    data.forEach((element) {
      IotWidget? iotWidget = SamIotWidgets.instance.collection
          .singleWhereOrNull((wgt) => wgt.id == element['widget_id']);
      if (iotWidget != null) {
        list.add(DashboardItem.fromJson(element));
      }
    });
  }

  return list;
}