readAsBytes method

Future<Uint8List> readAsBytes(
  1. File file
)

Reads all bytes from file with controlled concurrency.

Works like File.readAsBytes, but enforces the semaphore limit to avoid file handle exhaustion or disk saturation under parallel load.

Implementation

Future<Uint8List> readAsBytes(File file) async {
  await _semaphore.acquire();
  try {
    return await file.readAsBytes();
  } finally {
    _semaphore.release();
  }
}