pedometer 1.0.0 copy "pedometer: ^1.0.0" to clipboard
pedometer: ^1.0.0 copied to clipboard

outdated

A pedometer plugin for probing the native pedometer. Works for both iOS and Android and is written in Swift/Java.

pedometer #

pub package

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

When the application is started the step count is set to 0, and every time a step count update is registrered, the cumulative step count value since the app was started will be returned. The update frequency depends on the platform; iOS updates less frequently than Android.

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.

288
likes
0
pub points
96%
popularity

Publisher

verified publishercachet.dk

A pedometer plugin for probing the native pedometer. Works for both iOS and Android and is written in Swift/Java.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on pedometer