workout 0.0.5 workout: ^0.0.5 copied to clipboard
Run a workout session on Wear OS and Tizen. Get data such as heart rate in real time.
import 'package:flutter/material.dart';
import 'package:workout/workout.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
double heartRate = 0;
_MyAppState() {
final workout = Workout();
workout.start([WorkoutFeature.heartRate]);
workout.stream.listen((event) {
print('${event.feature}: ${event.value}');
if (event.feature == WorkoutFeature.heartRate) {
setState(() {
heartRate = event.value;
});
}
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Text('Heart rate: $heartRate'),
),
),
);
}
}