sfit_step_counter 0.0.21
sfit_step_counter: ^0.0.21 copied to clipboard
A lightweight Flutter package that detects steps in real-time using sensors_plus and provides calories, cadence, geofencing, and walking state.
example/sfit_step_counter_example.dart
import 'package:flutter/material.dart';
import 'package:step_counter/step_counter.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
final stepCounter = StepCounter();
await stepCounter.init(weightKg: 70, heightMeters: 1.75);
await stepCounter.start();
runApp(MyApp(stepCounter: stepCounter));
}
class MyApp extends StatelessWidget {
final StepCounter stepCounter;
const MyApp({required this.stepCounter});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Step Counter')),
body: StreamBuilder<StepData>(
stream: stepCounter.stepStream,
builder: (context, snapshot) {
final data = snapshot.data;
if (data == null) return Center(child: CircularProgressIndicator());
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Steps: ${data.steps}'),
Text('Calories: ${data.calories.toStringAsFixed(2)} kcal'),
Text('Speed: ${data.speedKmh.toStringAsFixed(2)} km/h'),
Text('Cadence: ${data.cadence.toStringAsFixed(2)} spm'),
Text('Status: ${data.status}')
],
);
},
),
),
);
}
}