fromMap static method

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

Implementation

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

  var actionFromMap = map['action'];
  if (actionFromMap != null) {
    actionFromMap =
        ActionEntity.fromMap(actionFromMap, newDocumentIds: newDocumentIds);
  }
  var imageIdNewDocmentId = map['imageId'];
  if ((newDocumentIds != null) && (imageIdNewDocmentId != null)) {
    var imageIdOldDocmentId = imageIdNewDocmentId;
    imageIdNewDocmentId = newRandomKey();
    newDocumentIds[imageIdOldDocmentId] = imageIdNewDocmentId;
  }
  var posSizeFromMap = map['posSize'];
  if (posSizeFromMap != null) {
    posSizeFromMap =
        PosSizeEntity.fromMap(posSizeFromMap, newDocumentIds: newDocumentIds);
  }

  return ListedItemEntity(
    description: map['description'],
    action: actionFromMap,
    imageId: imageIdNewDocmentId,
    posSize: posSizeFromMap,
  );
}