flutter_pedometer 0.9.2

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 83

Flutter Pedometer #

This plugin allows for conitnuous step count using the built-in pedometer sensor API's of iOS and Android devices.

Usage #

To use this plugin, add flutter_pedometer as a dependency in your pubspec.yaml file.

Example #

import 'dart:async';
import 'package:flutter_pedometer/flutter_pedometer.dart';

class someClass {
    StreamSubscription<int> _subscription;
    FlutterPedometer pedometer;
    
    void someFunction() async {
        // ...
        pedometer = new FlutterPedometer();
        _subscription = pedometer.stepCountStream.listen(_onData,
            onError: _onError, onDone: _onDone, cancelOnError: true);
    }
    
    void _onData(int stepCountValue) async {
        // Do something with the stepCountValue
    }
    
    void _onDone() {
        // Do something when done collecting
    }
    
    void _onError(error) {
        // Handle the error
    }

}
        

Configuring XCode for usage on iOS #

It seems that users of this plug-in will have to manually open XCode and configure a few settings manually, mostly pertaining to privacy settings and permissions due to the application collecting the user's movement data.

For usage on Android it seems there are no problems with permissions.

Flutter Errors #

Could not build the precompiled application for the device.
    ** BUILD FAILED **
    
Xcode's output:
↳
    === BUILD TARGET Runner OF PROJECT Runner WITH CONFIGURATION Debug ===
    The use of Swift 3 @objc inference in Swift 4 mode is deprecated. Please address deprecated @objc inference warnings, test your code with “Use of deprecated Swift 3 @objc inference” logging enabled, and then disable inference by changing the "Swift 3 @objc Inference" build setting to "Default" for the "Runner" target.
    The use of Swift 3 @objc inference in Swift 4 mode is deprecated. Please address deprecated @objc inference warnings, test your code with “Use of deprecated Swift 3 @objc inference” logging enabled, and then disable inference by changing the "Swift 3 @objc Inference" build setting to "Default" for the "Runner" target.
    === BUILD TARGET Runner OF PROJECT Runner WITH CONFIGURATION Debug ===
    fatal error: lipo: -extract armv7 specified but fat file: /Users/thomasnilsson/Desktop/testingoutmyplugin/build/ios/Debug-iphoneos/Runner.app/Frameworks/location.framework/location does not contain that architecture
    Failed to extract armv7 for /Users/thomasnilsson/Desktop/testingoutmyplugin/build/ios/Debug-iphoneos/Runner.app/Frameworks/location.framework/location. Running lipo -info:
    Architectures in the fat file: /Users/thomasnilsson/Desktop/testingoutmyplugin/build/ios/Debug-iphoneos/Runner.app/Frameworks/location.framework/location are: arm64 

Error launching application on Thomas’s iPhone.

Fix: Enable @objc inference #

7jcq5

Errors only visible when running through XCode #

screen shot 2018-08-07 at 16 04 31

Fix: Configure plist and capabilities #

Step 1: Open XCode #

Open the XCode project located at <your_project>/iOS/Runner.xcodeproj

Step 2: Set Capabilities #

screen shot 2018-08-08 at 10 09 11

Step 3: Configure your plist #

screen shot 2018-08-08 at 11 07 21

0.0.1 #

  • TODO: Describe initial release.

example/lib/main.dart

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

import 'package:flutter_pedometer/flutter_pedometer.dart';

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

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

class _MyAppState extends State<MyApp> {
  String _stepCountValue = 'Unknown';
  StreamSubscription<int> _subscription;

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    FlutterPedometer pedometer = new FlutterPedometer();
    _subscription = pedometer.stepCountStream.listen(_onData,
        onError: _onError, onDone: _onDone, cancelOnError: true);

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;
  }

  void _onData(int stepCountValue) async {
    print(stepCountValue);

    setState(() {
      _stepCountValue = "$stepCountValue";
    });
  }

  void _onDone() {}

  void _onError(error) {
    print("Flutter Pedometer Error: $error");
  }

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: const Text('Plugin example app'),
        ),
        body: new Center(
          child: new Text('Steps taken: $_stepCountValue\n'),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_pedometer: ^0.9.2

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_pedometer/flutter_pedometer.dart';
  
Version Uploaded Documentation Archive
0.9.2 Aug 22, 2018 Go to the documentation of flutter_pedometer 0.9.2 Download flutter_pedometer 0.9.2 archive
0.9.1 Aug 8, 2018 Go to the documentation of flutter_pedometer 0.9.1 Download flutter_pedometer 0.9.1 archive
0.9.0 Aug 7, 2018 Go to the documentation of flutter_pedometer 0.9.0 Download flutter_pedometer 0.9.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
75
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
83
Learn more about scoring.

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

  • Dart: 2.2.0
  • pana: 0.12.14
  • Flutter: 1.4.7

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health issues and suggestions

Document public APIs. (-1 points)

4 out of 4 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/flutter_pedometer.dart.

Run flutter format to format lib/flutter_pedometer.dart.

Maintenance issues and suggestions

Homepage URL doesn't exist. (-20 points)

At the time of the analysis the homepage field https://github.com/cph-cachet/flutter_pedometer was unreachable.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.1 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8