step_counter 0.0.2 copy "step_counter: ^0.0.2" to clipboard
step_counter: ^0.0.2 copied to clipboard

Flutter plugin that uses ObjC and Java to get a step count from HealthKit or the Google Fitness Store. The total steps today, steps during a time period, and steps during a time period in intervals ca [...]

example/lib/main.dart

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


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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: AccessSteps(),
    );
  }
}

class AccessSteps extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => _StepCounterState();
}

class _StepCounterState extends State<AccessSteps> {
  String _results = '';

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

  readAll() {
    String results = "";
    Future<int> stepCount = StepCounter.getStepsToday();
    stepCount.then((value) {
      results = value.toString();
      setState(() {
        _results = results;
      });
    }).catchError((error) {
      results = 'Failed to read all values. $error';
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Add Caravan'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'Total Steps for Today: $_results'
            ),
            FlatButton(
              onPressed: () => readAll(),
              child: Text("Reload"),
            ),
          ],
        ),
      )
    );
  }
}
4
likes
20
pub points
35%
popularity

Publisher

unverified uploader

Flutter plugin that uses ObjC and Java to get a step count from HealthKit or the Google Fitness Store. The total steps today, steps during a time period, and steps during a time period in intervals can all be queried.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on step_counter