workout 0.0.5 copy "workout: ^0.0.5" to clipboard
workout: ^0.0.5 copied to clipboard

outdated

Run a workout session on Wear OS and Tizen. Get data such as heart rate in real time.

example/lib/main.dart

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'),
        ),
      ),
    );
  }
}