accurate_step_counter library
Accurate step counter plugin with accelerometer-based detection
This plugin provides highly accurate step counting using:
- Accelerometer-based detection with low-pass filtering
- Peak detection algorithm for reliable step counting
- Configurable sensitivity parameters
- OS-level step counter sync (Android)
- Background tracking support
- Zero data loss across app states
Quick Start
import 'package:accurate_step_counter/accurate_step_counter.dart';
// Create instance
final stepCounter = AccurateStepCounter();
// Listen to step events
stepCounter.stepEventStream.listen((event) {
print('Steps: ${event.stepCount}');
});
// Start counting
await stepCounter.start();
// Stop counting
await stepCounter.stop();
Custom Configuration
// Start with custom sensitivity
await stepCounter.start(
config: StepDetectorConfig(
threshold: 1.2, // Movement threshold
filterAlpha: 0.85, // Smoothing factor
minTimeBetweenStepsMs: 250,
),
);
// Or use presets
await stepCounter.start(config: StepDetectorConfig.walking());
await stepCounter.start(config: StepDetectorConfig.running());
Classes
- AccurateStepCounter
- Main entry point for the accurate step counter plugin
- AccurateStepCounterImpl
- StepCountEvent
- Represents a step detection event
- StepDetectorConfig
- Configuration for the step detection algorithm
- StepLogsViewer
- A reusable widget that displays step logs for debugging purposes.
- StepRecord
- A record of steps taken during a time period
- StepRecordConfig
- Configuration for step recording behavior
- StepRecordStore
- Local store for step records using SQLite
Enums
- StepRecordSource
- Source of the step record