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

Libraries

flutter_pedometer

Dart

dart:ui
Built-in types and core primitives for a Flutter application. [...]

Core

dart:async
Support for asynchronous programming, with classes such as Future and Stream. [...]
dart:collection
Classes and utilities that supplement the collection support in dart:core. [...]
dart:convert
Encoders and decoders for converting between different data representations, including JSON and UTF-8. [...]
dart:core
Built-in types, collections, and other core functionality for every Dart program. [...]
dart:developer
Interact with developer tools such as the debugger and inspector. [...]
dart:math
Mathematical constants and functions, plus a random number generator. [...]
dart:typed_data
Lists that efficiently handle fixed sized data (for example, unsigned 8 byte integers) and SIMD numeric types. [...]

VM

dart:io
File, socket, HTTP, and other I/O support for non-web applications. [...]
dart:isolate
Concurrent programming using isolates: independent workers that are similar to threads but don't share memory, communicating only via messages. [...]