# fromEntity method Null safety

dynamic fromEntity(

1. String documentID,
2. DocumentEntity? entity

)

## Implementation

    static Future<DocumentModel?> fromEntity(
        String documentID, DocumentEntity? entity) async {
      if (entity == null) return null;
      var counter = 0;
      return DocumentModel(
        documentID: documentID,
        appId: entity.appId ?? '',
        description: entity.description,
        content: entity.content,
        padding: entity.padding,
        images: entity.images == null
            ? null
            : List<DocumentItemModel>.from(
                await Future.wait(entity.images!.map((item) {
                counter++;
                return DocumentItemModel.fromEntity(counter.toString(), item);
              }).toList())),
        background: await BackgroundModel.fromEntity(entity.background),
        conditions: await StorageConditionsModel.fromEntity(entity.conditions),
      );
    }