# pedometer 4.2.0

A Pedometer and Step Detection package for Android and iOS. Step count is streamed as the platform updates it.




## Installing
```
export PUB_HOSTED_URL=https://pub.mirror.p-hatan.com
flutter pub add pedometer
```
Published: 2026-02-24T07:47:02.538286Z
Expected archive SHA-256: 146d9663d4af6041328ac15cd96cdcd426b866d277d72f540f701193a61a193d

Available in cache; verification: upstream_checksum
## Direct dependencies
- flutter: map[sdk:flutter]

## Package README (untrusted upstream documentation)
# Pedometer

[![pub package](https://img.shields.io/pub/v/pedometer.svg)](https://pub.dartlang.org/packages/pedometer)

This plugin allows for continuous step counting and pedestrian status using the built-in pedometer sensor API of iOS and Android devices.

![](https://raw.githubusercontent.com/cph-cachet/flutter-plugins/master/packages/pedometer/imgs/screenshots.png)

## Permissions

For Android 10 and above add the following permission to the Android manifest:

```xml
<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />
```

For iOS, add the following entries to your Info.plist file in the Runner xcode project:

```xml
<key>NSMotionUsageDescription</key>
<string>This application tracks your steps</string>
<key>UIBackgroundModes</key>
<array>
    <string>processing</string>
</array>
```

## Step Count

The step count represents the number of steps taken since the last system boot.
On Android, any steps taken before installing the application will not be counted.

## Pedestrian Status

The Pedestrian status is either `walking` or `stopped`. In the case that of an error,
the status will be `unknown`.

## Availability of Sensors

Both Step Count and Pedestrian Status may not be available on some phones:

* It was found that some Samsung phones do not support Step Count or Pedestrian Status
* Older iPhones do not support Pedestrian Status in particular

In the case that the step sensor is not available, an error will be thrown. The application needs to handle this error.

## Example Usage

See the [example app](https://github.com/cph-cachet/flutter-plugins/blob/master/packages/pedometer/example/lib/main.dart) for a fully-fledged example.

Below is shown a more generalized example. Remember to set the required permissions, as described above. This may require you to manually allow the permission in the "Settings" on the phone.

``` dart
  Stream<StepCount> _stepCountStream;
  Stream<PedestrianStatus> _pedestrianStatusStream;

  /// Handle step count changed
  void onStepCount(StepCount event) {
    int steps = event.steps;
    DateTime timeStamp = event.timeStamp;
  }

  /// Handle status changed
  void onPedestrianStatusChanged(PedestrianStatus event) {
    String status = event.status;
    DateTime timeStamp = event.timeStamp;
  }

    /// Handle the error
  void onPedestrianStatusError(error) {}

  /// Handle the error
  void onStepCountError(error) {}

  Future<void> initPlatformState() async {
    // Init streams
    _pedestrianStatusStream = await Pedometer.pedestrianStatusStream;
    _stepCountStream = await Pedometer.stepCountStream;

    // Listen to streams and handle errors
    _stepCountStream.listen(onStepCount).onError(onStepCountError);

    _pedestrianStatusStream
      .listen(onPedestrianStatusChanged)
      .onError(onPedestrianStatusError);
  }
```

## Changelog
## 4.2.0

- Update Kotlin version
- Update Gradle version
- Enabled SPM support for iOS

## 4.1.1

- upgrading kotlin version
- upgrading agp version

## 4.1.0

- upgrading gradle version
- upgrading agp version
- upgrading kotlin version
- changing gradle file structure
- untracking files on git

## 4.0.2

- Updates Kotlin plugin and AGP.
- Upgrade of `compileSdkVersion` to 33.
- Upgrade to Dart 3.
- Small updates to example app (asking for permissions)

## 3.0.0

- Migrated to null safety

## 2.1.0

- Removed automatic error handling such as when the sensor is not available. This allows the plugin user to see when errors occur.

## 2.0.2

- Getters for streams are no longer async

## 2.0.1+2

- Downgraded `minSdkVersion` to 18 on Android
- It was set to 26 by mistake in a previous release

## 2.0.1+1

- Fixed image link

## 2.0.1

- Added error handling for when sensors are unavailable

## 2.0.0

- Re-implemented the plugin for both Android and iOS
- This should solve many build problems which persisted on Android
- Added Pedestrian Status events and the ability to stream these
- Added a class for the already-existing step count event

## 1.2.5

- Android 10 and above requires the Activity Recognition permission, this has been added to the docs.

## 1.2.0

- The plugin now returns the steps taken since last boot up.

## 1.1.0

- The Pedometer stream now returns the value since the plugin was started on both platforms.
- Previously this was only the case on iOS, and Android returned the steps taken since last phone boot-up.







 
