proximity_sensor
2.0.0, released 4 months ago by an unverified publisher
Flutter plugin to read proximity sensor events on Android and iOS
What it does
Provides a stream of proximity sensor changes and optional screen‑off behavior. It supports Android (min SDK 23) and iOS, handling necessary permissions and platform differences.
AI-written summary of version 2.0.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- When you need proximity sensor data for UI or logic
- When you want to turn off the screen while the device is close to a surface
- When building AR, gaming or accessibility features that rely on proximity
Skip it when
- When targeting Flutter versions below 3.44
- When using Android versions below 12 if you need WAKE_LOCK permission
Strengths
- Simple API with a single Stream
- Cross‑platform support (Android & iOS)
- Handles required permissions and platform quirks
Weaknesses
- Requires Flutter >=3.44 and Dart ^3.12
- Android 12+ needed for explicit exported activity
- No support for virtual proximity sensors on some devices
Setup
- Kind
- Plugin (native code)
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
Add dependency, import package, add <uses-permission android:name="android.permission.WAKE_LOCK"/> if using setProximityScreenOff(true). No build_runner needed.
import 'package:proximity_sensor/proximity_sensor.dart';
StreamSubscription? _subscription;
void startListening() {
_subscription = ProximitySensor.events.listen((event) {
print('Proximity: $event');
});
}
void stopListening() {
_subscription?.cancel();
}
Alternatives
Packages that do the same job and could replace proximity_sensor.
- sensors_plus
Flutter plugin to access accelerometer, gyroscope, magnetometer, and barometer sensors.
96Compare - proximity_screen_lock
Bind screen activation to proximity sensor and detect proximity events in Flutter.
60Compare - android_id
A Flutter plugin for retrieving the Android ID on Android devices.
87Compare - screen_state
Tracks screen state events on Android and iOS.
81Compare
Works with
Packages commonly used together with proximity_sensor: ones it builds on, ones built on it, and its own family.