Skip to content

Latest commit

 

History

History

light

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Light

pub package

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();
  }