readAsBytes method

Future<Uint8List> readAsBytes()

Reads and returns the raw file bytes. If bytes are already cached in memory, returns them immediately. Otherwise, reads from the local filesystem path on IO platforms.

Implementation

Future<Uint8List> readAsBytes() async {
  if (bytes != null && bytes!.isNotEmpty) {
    return bytes!;
  }
  if (!kIsWeb && path != null && path!.isNotEmpty) {
    return await io_helper.readFileBytes(path!);
  }
  throw StateError('Cannot read bytes for AdaptiveFile: no in-memory bytes and path is unavailable or does not exist ($path).');
}