Skip to content
pubscout

proximity_sensor

2.0.0, released 4 months ago by an unverified publisher

Flutter plugin to read proximity sensor events on Android and iOS

$ flutter pub add proximity_sensor
Source repository

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.

Works with

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