fromMap static method

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

Implementation

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

  var backgroundImageIdNewDocmentId = map['backgroundImageId'];
  if ((newDocumentIds != null) && (backgroundImageIdNewDocmentId != null)) {
    var backgroundImageIdOldDocmentId = backgroundImageIdNewDocmentId;
    backgroundImageIdNewDocmentId = newRandomKey();
    newDocumentIds[backgroundImageIdOldDocmentId] =
        backgroundImageIdNewDocmentId;
  }
  var shadowFromMap = map['shadow'];
  if (shadowFromMap != null) {
    shadowFromMap =
        ShadowEntity.fromMap(shadowFromMap, newDocumentIds: newDocumentIds);
  }
  var decorationColorsFromMap = map['decorationColors'];
  List<DecorationColorEntity> decorationColorsList;
  if (decorationColorsFromMap != null) {
    decorationColorsList = (map['decorationColors'] as List<dynamic>)
        .map((dynamic item) => DecorationColorEntity.fromMap(item as Map,
            newDocumentIds: newDocumentIds)!)
        .toList();
  } else {
    decorationColorsList = [];
  }
  var borderRadiusFromMap = map['borderRadius'];
  if (borderRadiusFromMap != null) {
    borderRadiusFromMap = BorderRadiusEntity.fromMap(borderRadiusFromMap,
        newDocumentIds: newDocumentIds);
  }
  var paddingFromMap = map['padding'];
  if (paddingFromMap != null) {
    paddingFromMap = EdgeInsetsGeometryEntity.fromMap(paddingFromMap,
        newDocumentIds: newDocumentIds);
  }
  var marginFromMap = map['margin'];
  if (marginFromMap != null) {
    marginFromMap = EdgeInsetsGeometryEntity.fromMap(marginFromMap,
        newDocumentIds: newDocumentIds);
  }

  return BackgroundEntity(
    backgroundImageId: backgroundImageIdNewDocmentId,
    useProfilePhotoAsBackground: map['useProfilePhotoAsBackground'],
    beginGradientPosition: map['beginGradientPosition'],
    endGradientPosition: map['endGradientPosition'],
    shadow: shadowFromMap,
    decorationColors: decorationColorsList,
    borderRadius: borderRadiusFromMap,
    border: map['border'],
    padding: paddingFromMap,
    margin: marginFromMap,
  );
}