fromEntity static method

Future<BackgroundModel?> fromEntity(
  1. BackgroundEntity? entity
)

Implementation

static Future<BackgroundModel?> fromEntity(BackgroundEntity? entity) async {
  if (entity == null) return null;
  var counter = 0;
  return BackgroundModel(
    useProfilePhotoAsBackground: entity.useProfilePhotoAsBackground,
    beginGradientPosition:
        toStartGradientPosition(entity.beginGradientPosition),
    endGradientPosition: toEndGradientPosition(entity.endGradientPosition),
    shadow: await ShadowModel.fromEntity(entity.shadow),
    decorationColors: entity.decorationColors == null
        ? null
        : List<DecorationColorModel>.from(
            await Future.wait(entity.decorationColors!.map((item) {
            counter++;
            return DecorationColorModel.fromEntity(counter.toString(), item);
          }).toList())),
    borderRadius: await BorderRadiusModel.fromEntity(entity.borderRadius),
    border: entity.border,
    padding: await EdgeInsetsGeometryModel.fromEntity(entity.padding),
    margin: await EdgeInsetsGeometryModel.fromEntity(entity.margin),
  );
}