Blob constructor

Blob(
  1. Iterable<Object> blobParts, {
  2. EndingType endings = EndingType.transparent,
  3. String type = '',
})

Creates a new Blob object from a String | TypedData | ArrayBuffer | Blob.

MDN Reference

Implementation

Blob(Iterable<Object> blobParts,
    {EndingType endings = EndingType.transparent, this.type = ''}) {
  _parts = blobParts.map(
    (e) => switch (e) {
      String value => (null, null, null, value.toLineTerminated(endings)),
      ArrayBuffer value => (null, value, null, null),
      TypedData value => (null, null, value, null),
      Blob value => (value, null, null, null),
      _ => throwUnsupportedError(e),
    },
  );
}