lightSensorStream property Null safety

Stream<int> lightSensorStream

A stream of light events. Throws an exception if device isn't on Android.

Implementation

Stream<int> get lightSensorStream {
  if (Platform.isAndroid) {
    if (_lightSensorStream == null) {
      _lightSensorStream =
          _eventChannel.receiveBroadcastStream().map((lux) => lux);
    }
    return _lightSensorStream!;
  }

  throw LightException('Light sensor API exclusively available on Android!');
}