Skip to content
pubscout

light

5.0.0, released 9 months ago by cachet.dk

Flutter plugin that streams ambient light sensor (lux) values on Android and iOS.

$ flutter pub add light
Source repository

What it does

Exposes a native ambient light sensor reading as a Dart stream of integer lux values. Handles iOS SensorKit entitlement and permission requests, while Android works without extra permissions.

AI-written summary of version 5.0.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need real‑time ambient light data for adaptive UI or research purposes
  • Your app runs on devices that support the ambient light sensor and you can obtain the required iOS entitlements

Skip it when

  • You cannot obtain the required SensorKit entitlement on iOS
  • Target devices lack an ambient light sensor
  • You only need a simple brightness level without sensor precision

Strengths

  • Simple API with a single stream
  • Supports both Android and iOS natively
  • Handles iOS permission flow internally

Weaknesses

  • iOS requires special entitlement and setup, making it hard for many apps
  • Limited to devices that expose an ambient light sensor
  • Only provides raw lux integers, no higher‑level processing

Setup

Kind
Plugin (native code)
Effort
High
Code generation
No
Direct dependencies
0

On iOS add the SensorKit entitlement (com.apple.developer.sensorkit.reader.allow) with ambient-light-sensor, include NSSensorKitUsageDetail in Info.plist, and request authorization via Light().requestAuthorization(). Android needs no extra permissions.

import 'dart:async';
import 'package:light/light.dart';

StreamSubscription<int>? _sub;

Future<void> start() async {
  await Light().requestAuthorization(); // no‑op on Android
  _sub = Light().lightSensorStream.listen((int lux) {
    print('Lux: $lux');
  });
}

void stop() => _sub?.cancel();

Alternatives

Packages that do the same job and could replace light.

  • sensors_plus

    Provides access to a wide range of device sensors without special iOS entitlements, useful if you need other sensors or want a simpler setup.

Works with

Packages commonly used together with light: ones it builds on, ones built on it, and its own family.