Skip to content

Latest commit

 

History

History
 
 

pedometer

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

pedometer

pub package

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

The step count returned is the number of steps since the phone was last booted.

Permissions for Android

No configuration needed.

Permissions for iOS

Users of this plug-in will have to manually open XCode and configure a few settings manually, mostly pertaining to privacy settings and permissions due to the application collecting the user's movement data.

Step 0:

Open the XCode project located at <your_project>/iOS/Runner.xcodeproj

Step 1: Set Capabilities

screen shot 2018-08-08 at 10 09 11

Step 2: Configure your plist

screen shot 2018-08-08 at 11 07 21

XCode Issue: Enabling @objc inference

7jcq5

Any errors are only visible when running through XCode, unfortunately. screen shot 2018-08-07 at 16 04 31

To use this plugin, add pedometer as a dependency in your pubspec.yaml file.

Example Usage

Pedometer _pedometer;
StreamSubscription<int> _subscription;

...
void onData(int stepCountValue) {
    print(stepCountValue);
}

void startListening() {
    _pedometer = new Pedometer();
    _subscription = _pedometer.pedometerStream.listen(_onData,
        onError: _onError, onDone: _onDone, cancelOnError: true);
}

void stopListening() {
    _subscription.cancel();
}

void _onData(int stepCountValue) async {
    setState(() => _stepCountValue = "$stepCountValue");
}

void _onDone() => print("Finished pedometer tracking");

void _onError(error) => print("Flutter Pedometer Error: $error");
        

Consult the example-app for a concrete implementation.