devicesfromJson static method

List<ScpDevice> devicesfromJson(
  1. dynamic json
)

Implementation

static List<ScpDevice> devicesfromJson(var json) {
  List<ScpDevice> devices = List<ScpDevice>.empty(growable: true);
  for (var j in json) {
    devices.add(
      ScpDevice(
        deviceId: j['deviceId'],
        deviceType: j['deviceType'],
        deviceName: j['deviceName'] != null ? j['deviceName'] : '',
        ipAddress: j['ipAddress'],
        isDefaultPasswordSet:
            j['isDefaultPasswordSet'] == 'false' ? false : true,
        knownPassword: j['knownPassword'],
        currentPasswordNumber: int.parse(j['currentPasswordNumber']),
        controlActions: j['controlActions'] != null
            ? Utils.dynamicListToStringList(j['controlActions'])
            : List<String>.empty(),
        measureActions: j['measureActions'] != null
            ? Utils.dynamicListToStringList(j['measureActions'])
            : List<String>.empty(),
      ),
    );
  }
  return devices;
}