toInternal method

Future<InternalPart> toInternal()

Implementation

Future<InternalPart> toInternal() async {
  if(this is public_types.TextPart){
    return InternalTextPart(asTextOrNull()!);
  }else if(this is public_types.ImagePart){
    final compressed = await compressToJpg(asImageOrNull()!);
   return InternalBlobPart(InternalBlob( mimeType: 'image/jpeg', data: base64Encode(compressed)));
  }else if(this is public_types.BlobPart){
    final t = this as public_types.BlobPart;
    return InternalBlobPart(InternalBlob( mimeType: t.mimeType, data: base64Encode(t.blob)));
  }
  else{
    throw public_types.SerializationException(
        "The given subclass of Part (${runtimeType.toString()}) is not supported in the serialization yet."
    );
  }
}