AssetMetadata.fromJson constructor

AssetMetadata.fromJson(
  1. Map<String, dynamic> json
)

Implementation

factory AssetMetadata.fromJson(Map<String, dynamic> json) {
  return AssetMetadata(
    assetTag: json['assetTag'],
    lastInspection: json['lastInspection'] != null
        ? DateTime.parse(json['lastInspection'])
        : null,
    nextMaintenance: json['nextMaintenance'] != null
        ? DateTime.parse(json['nextMaintenance'])
        : null,
    location: json['location'],
    installedBy: json['installedBy'],
    installationDate: json['installationDate'] != null
        ? DateTime.parse(json['installationDate'])
        : null,
    fieldMeasurements: json['fieldMeasurements'] != null
        ? (json['fieldMeasurements'] as List)
            .map((m) => FieldMeasurement.fromJson(m))
            .toList()
        : const [],
  );
}