light 0.1.0 copy "light: ^0.1.0" to clipboard
light: ^0.1.0 copied to clipboard

outdated

A Flutter plugin for probing data from the light sensor using a platform channel. Works for Android only, since the light sensor API is not available on iOS.

light #

A light sensor plugin for Flutter, reads the light intensity registered by the light sensor (in [Lux]), and reports this number back via a stream. The API for getting the light exposure is only available on Android devices, and the plugin will therefore not work for iOS devices.

Install #

Add light as a dependency in pubspec.yaml. For help on adding as a dependency, view the documentation.

Usage #

Al incoming data points are streamed with a StreamSubscription which is set up by calling the listen() method on the light.lightSensorStream stream object.

Given a method _onData(int lux) the subscription can be set up as follows:

Light _light;
StreamSubscription _subscription;
...
void onData(int luxValue) async {
    print("Lux value from Light Sensor: $luxValue");
}

void startListening() {
    _light = new Light();
    try {
      _subscription = _light.lightSensorStream.listen(onData);
    }
    on LightException catch (exception) {
      print(exception);
    }
}

The stream can also be cancelled again by calling the cancel() method:

  void stopListening() {
    _subscription.cancel();
  }
23
likes
0
pub points
90%
popularity

Publisher

verified publishercachet.dk

A Flutter plugin for probing data from the light sensor using a platform channel. Works for Android only, since the light sensor API is not available on iOS.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on light