section method

Uint8List section(
  1. String name
)

One section's bytes. Throws ArgumentError for a name not carried.

Implementation

Uint8List section(String name) {
  final ({int offset, int length})? found = _sections[name];
  if (found == null) {
    throw ArgumentError.value(name, 'name', 'no such section');
  }
  final RandomAccessFile file = File(_file).openSync();
  try {
    file.setPositionSync(_offset + found.offset);
    return file.readSync(found.length);
  } finally {
    file.closeSync();
  }
}