simple_step_history 0.0.7

  • Readme
  • Changelog
  • Example
  • Installing
  • 57

simple_step_history #

A simple steps history fetcher. #

  • iOS with CMPedometer API
  • Android with GoogleFit API

Functionality: #

  • Request Authorization 'SimpleStepHistory.requestAuthorization()'
  • Check is steps available or not 'SimpleStepHistory.isStepsAvailable'
  • Fetch steps history by date 'SimpleStepHistory.getStepsForDay(dateStr: 'yyyy-MM-dd')'

Note #

  • Make sure to add privacy request string in iOS info.plist
  • Make sure to add GoogleFit API in your google developer console

0.0.7 #

  • Fix uithread crash in android

0.0.3 #

  • Remove android cal log

0.0.2 #

  • Fix iOS example

0.0.1 #

  • Initial implementation of steps history fetcher
  • TODO: proper error handler

example/lib/main.dart

import 'dart:async';

import 'package:intl/intl.dart';
import 'package:flutter/material.dart';
import 'package:simple_step_history/simple_step_history.dart';

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

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

class _MyAppState extends State<MyApp> {
  var data = List<String>();
  var stepAvailable = false;

  @override
  void initState() {
    super.initState();
    // initStepsAvailability();
    requestSteps();
  }

  Future<void> requestSteps() async {
    final granted = await SimpleStepHistory.requestAuthorization();
    setState(() => stepAvailable = granted);
  }

  Future<void> initStepsAvailability() async {
    final available = await SimpleStepHistory.isStepsAvailable;
    setState(() => stepAvailable = available);
  }

  Future<void> getWeekSteps() async {
    data = [];
    final fmt = DateFormat('yyyy-MM-dd');
    for (var i = 0; i < 7; i++) {
      final date = DateTime.now().subtract(Duration(days: i));
      final str = fmt.format(date);
      final steps = await SimpleStepHistory.getStepsForDay(dateStr: str);
      data.add('DATE: $str - COUNT: ${steps < 0 ? 'N/A' : '$steps'}');
    }
    setState(() {});
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
          appBar: AppBar(
            title: const Text('Plugin example app'),
            actions: <Widget>[
              IconButton(
                icon: Icon(Icons.file_download),
                onPressed: () => getWeekSteps(),
              )
            ],
          ),
          body: Column(
            children: <Widget>[
              Text('IsStepAvailable : ${stepAvailable ? true : false}'),
              Expanded(
                child: ListView.builder(
                  itemCount: data.length,
                  itemBuilder: (ctx, idx) {
                    return ListTile(title: Text(data[idx]));
                  },
                ),
              ),
            ],
          )),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  simple_step_history: ^0.0.7

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:simple_step_history/simple_step_history.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
28
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
68
Overall:
Weighted score of the above. [more]
57
Learn more about scoring.

We analyzed this package on Apr 8, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health issues and suggestions

Document public APIs. (-1 points)

6 out of 6 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/simple_step_history.dart.

Run flutter format to format lib/simple_step_history.dart.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (intl).

The package description is too short. (-12 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
intl ^0.15.7 0.15.8 0.16.1
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
path 1.6.4
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8