Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions packages/sensors_plus/sensors_plus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

[<img src="../../../assets/flutter-favorite-badge.png" width="100" />](https://flutter.dev/docs/development/packages-and-plugins/favorites)

A Flutter plugin to access the accelerometer, gyroscope, magnetometer and
A Flutter plugin to access the accelerometer, gyroscope, magnetometer and
barometer sensors.

## Platform Support
Expand All @@ -23,15 +23,15 @@ barometer sensors.
- Dart >=3.3.0 <4.0.0
- iOS >=12.0
- macOS >=10.14
- Android `compileSDK` 34
- Java 17
- Android Gradle Plugin >=8.3.0
- Gradle wrapper >=8.4
- Kotlin 2.2.0
- Android Gradle Plugin >=8.12.1
- Gradle wrapper >=8.13

## Usage

Add `sensors_plus` as a dependency in your pubspec.yaml file.

On iOS you must also include a key called [`NSMotionUsageDescription`](https://developer.apple.com/documentation/bundleresources/information_property_list/nsmotionusagedescription) in your app's `Info.plist` file. This key provides a message that tells the user why the app is requesting access to the device’s motion data. The plugin itself needs access to motion data to get barometer data.

Example Info.plist entry:
Expand Down Expand Up @@ -67,7 +67,7 @@ The plugin exposes such classes of sensor events through a set of streams:
- `GyroscopeEvent` describes the rotation of the device.
- `MagnetometerEvent` describes the ambient magnetic field surrounding the
device. A compass is an example usage of this data.
- `BarometerEvent` describes the atmospheric pressure surrounding the device, in hPa.
- `BarometerEvent` describes the atmospheric pressure surrounding the device, in hPa.
An altimeter is an example usage of this data. Not supported on web browsers.

These events are exposed through a `BroadcastStream`: `accelerometerEvents`,
Expand Down Expand Up @@ -173,27 +173,27 @@ sensor data.

### Platform Restrictions and Considerations

The following lists the restrictions for the sensors on certain platforms due to limitations of the platform.
The following lists the restrictions for the sensors on certain platforms due to limitations of the platform.

- **Magnetometer and Barometer missing for web**

The Magnetometer API is currently not supported by any modern web browsers. Check browser compatibility matrix on [MDN docs for Magnetormeter API](https://developer.mozilla.org/en-US/docs/Web/API/Magnetometer).
The Magnetometer API is currently not supported by any modern web browsers. Check browser compatibility matrix on [MDN docs for Magnetormeter API](https://developer.mozilla.org/en-US/docs/Web/API/Magnetometer).

The Barometer API does not exist for web platforms as can be seen at [MDN docs forn Sensors API](https://developer.mozilla.org/en-US/docs/Web/API/Sensor_APIs).
The Barometer API does not exist for web platforms as can be seen at [MDN docs forn Sensors API](https://developer.mozilla.org/en-US/docs/Web/API/Sensor_APIs).

Developers should consider alternative methods or inform users about the limitation when their application runs on a web platform.
Developers should consider alternative methods or inform users about the limitation when their application runs on a web platform.

> [!NOTE]
>
> Plugin won't crash the app in the case of usage on these platforms, but it is highly recommended to add onError() to handle such cases gracefully.

- **Sampling periods for web**

Currently it is not possible to set sensors sampling rate on web. Calls to event streams at specied sampling periods will have the sampling period ignored.
Currently it is not possible to set sensors sampling rate on web. Calls to event streams at specied sampling periods will have the sampling period ignored.

- **Barometer sampling period limitation for iOS**

On iOS devices, barometer updates are [CMAltimeter](https://developer.apple.com/documentation/coremotion/cmaltimeter) which provides updates at regular intervals that cannot be controlled by the user. Calls to `barometerEventStream` at specied sampling periods will have the sampling period ignored.
On iOS devices, barometer updates are [CMAltimeter](https://developer.apple.com/documentation/coremotion/cmaltimeter) which provides updates at regular intervals that cannot be controlled by the user. Calls to `barometerEventStream` at specied sampling periods will have the sampling period ignored.

## Learn more

Expand Down
7 changes: 3 additions & 4 deletions packages/sensors_plus/sensors_plus/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ group 'dev.fluttercommunity.plus.sensors'
version '1.0-SNAPSHOT'

buildscript {
ext.kotlin_version = '1.7.22'
ext.kotlin_version = '2.2.0'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:8.3.1'
classpath 'com.android.tools.build:gradle:8.12.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand All @@ -25,9 +25,8 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
compileSdk 34

namespace 'dev.fluttercommunity.plus.sensors'
compileSdk = flutter.compileSdkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_17
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if (flutterVersionName == null) {
}

android {
compileSdk 34
compileSdk = flutter.compileSdkVersion

namespace 'io.flutter.plugins.sensorsexample'

Expand All @@ -41,8 +41,8 @@ android {

defaultConfig {
applicationId "io.flutter.plugins.sensorsexample"
minSdk 21
targetSdk 34
minSdk flutter.minSdkVersion
targetSdk flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ pluginManagement {

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.3.1" apply false
id "com.android.application" version "8.12.1" apply false
id "org.jetbrains.kotlin.android" version "2.2.0" apply false
}

include ":app"
Loading