fromMap static method

PresentationEntity? fromMap(
  1. Object? o, {
  2. Map<String, String>? newDocumentIds,
})

Implementation

static PresentationEntity? fromMap(Object? o,
    {Map<String, String>? newDocumentIds}) {
  if (o == null) return null;
  var map = o as Map<String, dynamic>;

  var bodyComponentsFromMap = map['bodyComponents'];
  List<BodyComponentEntity> bodyComponentsList;
  if (bodyComponentsFromMap != null) {
    bodyComponentsList = (map['bodyComponents'] as List<dynamic>)
        .map((dynamic item) => BodyComponentEntity.fromMap(item as Map,
            newDocumentIds: newDocumentIds)!)
        .toList();
  } else {
    bodyComponentsList = [];
  }
  var imageIdNewDocmentId = map['imageId'];
  if ((newDocumentIds != null) && (imageIdNewDocmentId != null)) {
    var imageIdOldDocmentId = imageIdNewDocmentId;
    imageIdNewDocmentId = newRandomKey();
    newDocumentIds[imageIdOldDocmentId] = imageIdNewDocmentId;
  }
  var conditionsFromMap = map['conditions'];
  if (conditionsFromMap != null) {
    conditionsFromMap = StorageConditionsEntity.fromMap(conditionsFromMap,
        newDocumentIds: newDocumentIds);
  }

  return PresentationEntity(
    appId: map['appId'],
    description: map['description'],
    bodyComponents: bodyComponentsList,
    imageId: imageIdNewDocmentId,
    imagePositionRelative: map['imagePositionRelative'],
    imageAlignment: map['imageAlignment'],
    imageWidth: double.tryParse(map['imageWidth'].toString()),
    conditions: conditionsFromMap,
  );
}