Search packages, repositories and app categories

Package detailsv2.0.0

proximity_sensor

simple and easy to use flutter plugin package for proximity sensor (only)

AndroidiOS
30-day downloads
41.8K
Likes
48
Pub points
160

Install package

flutter pub add proximity_sensor

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

The proximity_sensor package is a lightweight Flutter plugin designed to simplify access to the device's proximity sensor on Android and iOS. It enables apps to detect when an object is near the device, commonly used for features like automatically turning off the screen during phone calls. The plugin provides a straightforward API with minimal setup, making it ideal for developers seeking basic proximity detection without additional complexity. It supports both major mobile platforms and integrates seamlessly into existing Flutter projects.

Use cases

  • Auto screen dimming during calls
  • Gesture-based interaction detection
  • Proximity-triggered app behaviors
  • Device orientation awareness
  • Smart wake-up from sleep mode

Key features

  • Simple, minimal API
  • Cross-platform support (Android & iOS)
  • Real-time proximity event listening
  • Lightweight and fast
  • No additional dependencies

Suitable for

  • Mobile apps needing proximity detection
  • Call interface enhancements
  • IoT device interaction
  • Accessibility features
  • Low-level sensor integration

Considerations

  • Limited to proximity sensor only
  • Requires device hardware support
  • No fallback for unsupported devices
  • Platform-specific behavior differences
  • Sensor accuracy may vary by device

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

proximity_sensor

https://pub.dev/packages/proximity_sensor

simple and easy to use flutter plugin package for proximity sensor (only)

Getting started

In the pubspec.yaml of your flutter project, add the following dependency:

dependencies:
  ...
  proximity_sensor:

In your library add the following import:

import 'package:proximity_sensor/proximity_sensor.dart';

Note

Android 12 and higher are required to specify an explicit value for android:exported
This is an example.

<activity
    android:exported="true"
    ....

(Android only) WAKE_LOCK permission is needed if you run setProximityScreenOff(true) before listening to events

Add below permission in your AndroidManifest.xml file.

<uses-permission android:name="android.permission.WAKE_LOCK"/>

Some recent devices use virtual proximity sensors. There are no physical sensors. I found it hard to trust the sensor information in this case.

Categories

Source repository

Projects using this package