getByteData method
Requests the original image for that asset.
You can also pass the optional parameter quality
to reduce the quality
and the size of the returned image if needed. The value should be between
0 and 100. By default it set to 100 (max quality).
The method returns a Future with the ByteData for the image, as well as storing it in the _imageData property which can be requested later again, without need to call this method again.
Implementation
Future<ByteData> getByteData({int quality = 100}) async {
if (quality < 0 || quality > 100) {
throw new ArgumentError.value(
quality, 'quality should be in range 0-100');
}
Completer completer = new Completer<ByteData>();
ServicesBinding.instance!.defaultBinaryMessenger
.setMessageHandler(_originalChannel, (ByteData? message) async {
completer.complete(message);
ServicesBinding.instance!.defaultBinaryMessenger
.setMessageHandler(_originalChannel, null);
return message;
});
await MultiImagePicker.requestOriginal(_identifier, quality);
return completer.future as FutureOr<ByteData>;
}