stop static method

Future<void> stop()

Flush any remaining events and shut down the recording session.

Implementation

static Future<void> stop() async {
  if (!isEnabled) return;
  isEnabled = false;
  _stopwatch.stop();

  if (_writeIndex > 0) {
    // Send the partially filled buffer
    final copy = _createBuffer(_writeIndex);
    List.copyRange(copy, 0, _activeBuffer, 0, _writeIndex);
    _sink!.add(copy, const [], _activeMetadata);
  }

  _writeIndex = 0;
  _activeMetadata = {};
  _activeBuffer.fillRange(0, _activeBuffer.length, 0);

  await _sink!.close();
  _sink = null;
}