getOriginBytes method
Future<Uint8List?>
getOriginBytes({
- PMProgressHandler? progressHandler,
- PMCancelToken? cancelToken,
Obtain the raw data of the asset.
Use it with caution since the original data might be epic large. Generally use this method only for images.
progressHandleris used to handle the progress of the raw data loading process.cancelTokenis used to cancel the raw data loading process.
Implementation
Future<typed_data.Uint8List?> getOriginBytes({
PMProgressHandler? progressHandler,
PMCancelToken? cancelToken,
}) async {
assert(
_platformMatched,
'${Platform.operatingSystem} does not support obtain raw data.',
);
if (!_platformMatched) {
return null;
}
if (Platform.isAndroid) {
final sdkInt = int.parse(await plugin.getSystemVersion());
if (sdkInt > 29) {
return plugin.getOriginBytes(
id,
progressHandler: progressHandler,
cancelToken: cancelToken,
);
}
}
if (PlatformUtils.isOhos) {
return plugin.getOriginBytes(
id,
progressHandler: progressHandler,
cancelToken: cancelToken,
);
}
final File? file = await originFile;
return file?.readAsBytes();
}