readDouble method

Future<double> readDouble()

Reads and returns an 8-byte double, using the current endian setting.

Throws EOFException if EOF is reached before the needed bytes are read.

Implementation

Future<double> readDouble() async {
  await _ensureNext();
  if (_curr!.length - _pos < 8) {
    // If we're on a buffer boundary
    // Keep it simple
    return (await readByteDataImmutable(8)).getFloat64(0, endian);
  } else {
    final result = _curr!.buffer
        .asByteData()
        .getFloat64(_pos + _curr!.offsetInBytes, endian);
    _pos += 8;
    return result;
  }
}