sfit_step_counter 0.0.9 copy "sfit_step_counter: ^0.0.9" to clipboard
sfit_step_counter: ^0.0.9 copied to clipboard

Step Counter is a lightweight Flutter package that detects steps in real-time using the accelerometer via sensors_plus.

๐Ÿƒ Step Counter #

A lightweight Flutter package to help you count steps using the device's gyroscope and Kalman filtering. This package is a modern alternative to deprecated or unstable step tracking packages like health and pedometer, which often crash on certain devices.

Built with simplicity, performance, and compatibility in mind.


๐Ÿš€ Features #

  • ๐Ÿ“ฑ Step detection using sensors_plus

  • ๐Ÿ“Š Real-time step stream

  • ๐Ÿ” Simple API: start(), stop(), reset()

  • ๐Ÿ”ฅ Calculates:

    • Total steps
    • Calories burned
    • Walking speed (km/h)
  • โš™๏ธ Lightweight Kalman filter for noise reduction

  • โœ… No activity recognition dependency required


๐Ÿงช Usage #

import 'package:sfit_step_counter/sfit_step_counter.dart';

final stepCounter = StepCounter();

await stepCounter.init(weightKg: 68, heightMeters: 1.72);

stepCounter.start();

stepCounter.stepStream.listen((steps) {
  print('Steps: $steps');
  print('Calories: ${stepCounter.caloriesBurned.toStringAsFixed(2)} kcal');
  print('Speed: ${stepCounter.walkingSpeedKmh.toStringAsFixed(2)} km/h');
});

๐Ÿ” Permissions #

Youโ€™ll need to request the activity recognition permission:

import 'package:permission_handler/permission_handler.dart';

Future<void> requestPermissions() async {
  if (await Permission.activityRecognition.request().isGranted) {
    // Permission granted
  }
}

๐Ÿ›  Android Setup #

Update your AndroidManifest.xml:

<!-- Required Permissions -->
<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

Inside the <application> tag:

<application
    android:label="your_app_name"
    android:icon="@mipmap/ic_launcher"
    android:usesCleartextTraffic="true">

    <!-- Required for background execution -->
    <service
        android:name="com.pravera.flutter_background.FlutterBackgroundService"
        android:enabled="true"
        android:exported="false"/>

    <receiver
        android:enabled="true"
        android:exported="true"
        android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED"/>
            <action android:name="android.intent.action.QUICKBOOT_POWERON"/>
            <action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
        </intent-filter>
    </receiver>
</application>

Also update android/app/build.gradle:

defaultConfig {
  minSdkVersion 21
  // other configs...
}

๐Ÿ“ฆ Installing #

Add to your pubspec.yaml:

dependencies:
  sfit_step_counter: ^0.0.9

๐Ÿ™ Thanks #

Thank you for using this package! If you find it useful, feel free to like on pub.dev and share with fellow Flutter developers.

Happy coding! ๐Ÿ˜Š

4
likes
0
points
76
downloads

Publisher

unverified uploader

Weekly Downloads

Step Counter is a lightweight Flutter package that detects steps in real-time using the accelerometer via sensors_plus.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, flutter_background, sensors_plus, shared_preferences

More

Packages that depend on sfit_step_counter