fromMap static method

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

Implementation

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

  var imagesFromMap = map['images'];
  List<DocumentItemEntity> imagesList;
  if (imagesFromMap != null) {
    imagesList = (map['images'] as List<dynamic>)
        .map((dynamic item) => DocumentItemEntity.fromMap(item as Map,
            newDocumentIds: newDocumentIds)!)
        .toList();
  } else {
    imagesList = [];
  }
  var backgroundFromMap = map['background'];
  if (backgroundFromMap != null) {
    backgroundFromMap = BackgroundEntity.fromMap(backgroundFromMap,
        newDocumentIds: newDocumentIds);
  }
  var conditionsFromMap = map['conditions'];
  if (conditionsFromMap != null) {
    conditionsFromMap = StorageConditionsEntity.fromMap(conditionsFromMap,
        newDocumentIds: newDocumentIds);
  }

  return DocumentEntity(
    appId: map['appId'],
    description: map['description'],
    content: map['content'],
    padding: double.tryParse(map['padding'].toString()),
    images: imagesList,
    background: backgroundFromMap,
    conditions: conditionsFromMap,
  );
}