step_logger 1.0.0-beta.4 copy "step_logger: ^1.0.0-beta.4" to clipboard
step_logger: ^1.0.0-beta.4 copied to clipboard

A Flutter plugin for step counting and log sessions with background service support for Android and iOS.

Step Logger πŸšΆβ€β™‚οΈ #

Version Platforms

A Flutter plugin for cross-platform step tracking with background support.

Features #

  • πŸ“Š Real-time step counting
  • πŸ”„ Background service for continuous tracking (Android)
  • πŸ“… Historical session data storage
  • πŸ”” Customizable notification
  • πŸ“± Works in foreground and background
  • πŸ”„ Automatic session recovery after app kills

Platform Support #

Feature Android iOS
Real-time steps βœ… βœ…
Background tracking βœ… ⚠️ Limited
Session history βœ… βœ…
Step accuracy High High
Battery impact Moderate Low

Android Setup #

Permissions βš™οΈ #

Add to android/app/src/main/AndroidManifest.xml:

<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.BODY_SENSORS" />
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />

<!-- For Android 9+ background execution -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_HEALTH" />

Service declaration #

   <service
      android:name="com.transistorsoft.flutter.backgroundfetch.BackgroundFetchService"
      android:permission="android.permission.BIND_JOB_SERVICE"
      android:exported="true" />

  <service
      android:name="id.flutter.flutter_background_service.BackgroundService"
      android:foregroundServiceType="health"/>

  <service
      android:name="com.your.example_app.ForegroundService"
      android:enabled="true"
      android:exported="false" />                  

iOS Setup #

Requirements #

  1. Add HealthKit entitlement:

    • In Xcode, go to your target's Signing & Capabilities.
    • Click "+" and add HealthKit.
  2. Add these entries to your Info.plist:

<key>NSHealthShareUsageDescription</key>
<string>We need access to HealthKit to track your steps</string>
<key>NSHealthUpdateUsageDescription</key>
<string>We need access to HealthKit to save your step data</string>
<key>UIBackgroundModes</key>
<array>
  <string>fetch</string>
  <string>healthkit</string>
</array>

<!-- Notification-->
<key>NSUserNotificationAlertStyle</key>
<string>alert</string>

iOS Limitations #

⚠️ Important iOS Considerations

  1. Background step updates require explicit user permission.

  2. Steps are only recorded when:

    • The app is in the foreground.
    • The user has HealthKit background delivery enabled.
    • The user opens the app periodically (to sync latest data).
  3. Step data accuracy depends on the device

  4. Sessions interrupted by app kills will:

    • Persist tracking state.
    • Recover steps when the app relaunches.
    • Auto-stop sessions older than 12 hours.

Note: iOS does not support true background step tracking services like Android. The plugin uses HealthKit background delivery as a workaround, which depends on system scheduling and user permissions. This means background updates may be delayed or less frequent compared to Android, and step counts are calculated when the app is brought to the foreground.

4
likes
140
points
74
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin for step counting and log sessions with background service support for Android and iOS.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

dependency_validator, flutter, flutter_background_service, flutter_local_notifications, health, intl, pedometer, permission_handler, plugin_platform_interface, shared_preferences

More

Packages that depend on step_logger

Packages that implement step_logger