sensorEvents property

Stream<SensorEvent> get sensorEvents

Get the stream of sensor events.

Use the setSamplingRate method to set the sampling rate. Note that the sampling rate must be set before listening is started.

Throws an ESenseException if not connected to an eSense device. Wait until connected before using this stream.

Implementation

Stream<SensorEvent> get sensorEvents {
  if (!connected) {
    throw ESenseException('Not connected to any eSense device.');
  }

  return _sensorStream ??= _eSenseSensorEventChannel
      .receiveBroadcastStream()
      .map((event) =>
          event is Map ? SensorEvent.fromMap(event) : SensorEvent.empty());
}