fromMap static method

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

Implementation

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

  var itemCardBackgroundFromMap = map['itemCardBackground'];
  if (itemCardBackgroundFromMap != null) {
    itemCardBackgroundFromMap = BackgroundEntity.fromMap(
        itemCardBackgroundFromMap,
        newDocumentIds: newDocumentIds);
  }
  var addToCartColorFromMap = map['addToCartColor'];
  if (addToCartColorFromMap != null) {
    addToCartColorFromMap = RgbEntity.fromMap(addToCartColorFromMap,
        newDocumentIds: newDocumentIds);
  }
  var buyActionFromMap = map['buyAction'];
  if (buyActionFromMap != null) {
    buyActionFromMap = ActionEntity.fromMap(buyActionFromMap,
        newDocumentIds: newDocumentIds);
  }
  var openProductActionFromMap = map['openProductAction'];
  if (openProductActionFromMap != null) {
    openProductActionFromMap = ActionEntity.fromMap(openProductActionFromMap,
        newDocumentIds: newDocumentIds);
  }
  var paddingFromMap = map['padding'];
  if (paddingFromMap != null) {
    paddingFromMap = EdgeInsetsGeometryEntity.fromMap(paddingFromMap,
        newDocumentIds: newDocumentIds);
  }
  var conditionsFromMap = map['conditions'];
  if (conditionsFromMap != null) {
    conditionsFromMap = StorageConditionsEntity.fromMap(conditionsFromMap,
        newDocumentIds: newDocumentIds);
  }

  return ShopFrontEntity(
    appId: map['appId'],
    title: map['title'],
    description: map['description'],
    shopId: map['shopId'],
    size: double.tryParse(map['size'].toString()),
    cardElevation: double.tryParse(map['cardElevation'].toString()),
    cardAxisSpacing: double.tryParse(map['cardAxisSpacing'].toString()),
    itemCardBackground: itemCardBackgroundFromMap,
    addToCartColor: addToCartColorFromMap,
    scrollDirection: map['scrollDirection'],
    buyAction: buyActionFromMap,
    openProductAction: openProductActionFromMap,
    padding: paddingFromMap,
    conditions: conditionsFromMap,
  );
}