read method

  1. @override
Future<Uint8List?> read({
  1. int? start,
  2. int? end,
})
override

Implementation

@override
Future<Uint8List?> read({int? start, int? end}) async {
  try {
    // already read
    if (bytes != null) return bytes;

    // filepicker format read from file
    if (file is universal_html.File) {
      if ((start == null) && (end == null)) {
        bytes = await _read();
      } else {
        return await _readPart(start, end);
      }
    }

    // camera format. read from blob
    if (file is XFile) {
      bytes = await file.readAsBytes();
    }

    return bytes;
  } catch (e) {
    Log().exception(e);
    return null;
  }
}