light 4.0.0  light: ^4.0.0 copied to clipboard
light: ^4.0.0 copied to clipboard
Plugin for collecting data from the ambient light sensor on Android.
Light #
A Flutter plugin for collecting ambient light data from the Android Environment Sensors.
Install #
Add light as a dependency in the pubspec.yaml file.
For help on adding as a dependency, view the documentation.
Usage #
Use the singleton Light() to listen on the lightSensorStream stream.
  StreamSubscription<int>? _lightEvents;
  void startListening() {
    try {
      _lightEvents =
          Light().lightSensorStream.listen((luxValue) => setState(() {
                // Do something with the lux value
              }));
    } catch (exception) {
      print(exception);
    }
  }
  void stopListening() {
    _lightEvents?.cancel();
  }