fit_kit 0.0.1 copy "fit_kit: ^0.0.1" to clipboard
fit_kit: ^0.0.1 copied to clipboard

discontinuedreplaced by: health
outdated

Flutter plugin for reading health and fitness data. Wraps HealthKit on iOS and GoogleFit on Android.

example/lib/main.dart

import 'dart:convert';

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:fit_kit/fit_kit.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _results = 'Unknown';

  @override
  void initState() {
    super.initState();
    readAll();
  }

  Future<void> readAll() async {
    String results = "";

    try {
      for (DataType type in DataType.values) {
        final response = await FitKit.read(
          type,
          DateTime.now().subtract(Duration(days: 5)),
          DateTime.now(),
        );

        final result = "Type $type = ${response.length} ${response.map((data) => data.value)}\n\n\n";
        results += result;
        debugPrint(result);
      }
    } catch (e) {
      results = 'Failed to read all values. $e';
    }

    if (!mounted) return;

    setState(() {
      _results = results;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: SingleChildScrollView(
            child: Text('$_results'),
          ),
        ),
      ),
    );
  }
}
45
likes
0
pub points
56%
popularity

Publisher

unverified uploader

Flutter plugin for reading health and fitness data. Wraps HealthKit on iOS and GoogleFit on Android.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on fit_kit