asBlob method

Future<Blob> asBlob({
  1. String? type,
  2. double? quality,
})

Implementation

Future<Blob> asBlob({String? type, double? quality}) async {
  var completer = Completer<Blob>();

  var callback = (Blob blob) {
    completer.complete(blob);
  }.toJS;

  if (quality != null) {
    type ??= 'image/png';
    toBlob(callback, type, quality.toJS);
  } else if (type != null) {
    toBlob(callback, type);
  } else {
    toBlob(callback);
  }

  return completer.future;
}