awareframework_core 0.1.0

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

awareframework_core

A new flutter plugin project.

Developing Aware Plugin for Flutter

Flutter

  1. Make a template app using flutter command
$ flutter create --org com.awareframework.sample --template=plugin -i swift -a kotlin awareframework_sample
  1. Add the awareframework_core into your pubspec.yaml
dependencies:
  awareframework_core:

You can get more information about the package installation via the following link.

  1. Implement your sensor using the core-library
/// The Accelerometer Sensor class
class AccelerometerSensor extends AwareSensor {

  /// Accelerometer Method Channel
  static const MethodChannel _accelerometerMethod = const MethodChannel('awareframework_accelerometer/method');

  /// Accelerometer Event Channel
  static const EventChannel  _accelerometerStream  = const EventChannel('awareframework_accelerometer/event');

  /// Init Accelerometer Sensor with AccelerometerSensorConfig
  AccelerometerSensor(AccelerometerSensorConfig config):this.convenience(config);
  AccelerometerSensor.convenience(config) : super(config){
    super.setMethodChannel(_accelerometerMethod);
  }

  Stream<Map<String,dynamic>> get onDataChanged {
     return super.getBroadcastStream( _accelerometerStream, "on_data_changed").map((dynamic event) => Map<String,dynamic>.from(event));
  }

  @override
  void cancelAllEventChannels() {
    super.cancelBroadcastStream("on_data_changed");
  }

}

///
/// The Sensor Configuration Parameter class
///
class AccelerometerSensorConfig extends AwareSensorConfig {

  int frequency    = 5;
  double period    = 1.0;
  double threshold = 0.0;

  AccelerometerSensorConfig();

  @override
  Map<String, dynamic> toMap() {
    var map = super.toMap();
    map['frequency'] = frequency;
    map['period']    = period;
    map['threshold'] = threshold;
    return map;
  }
}

Android


iOS

  1. Add following code into ios/awareframework_sample.podspec
  # update author information and url
  s.dependency 'awareframework_core'
  s.ios.deployment_target = '10.0'
  # add other dependency
  1. Run pod install at example/ios

  2. Open iOS project (example/ios/Runner.xcworkspace) and change a deplyment target to 10.0

import Flutter
import UIKit
import com_awareframework_ios_sensor_accelerometer
import com_awareframework_ios_sensor_core
import awareframework_core

public class SwiftAwareframeworkAccelerometerPlugin: AwareFlutterPluginCore, FlutterPlugin, AwareFlutterPluginSensorInitializationHandler, AccelerometerObserver{
        
    var accelerometerSensor:AccelerometerSensor?
    
    public override init() {
        super.init()
        super.initializationCallEventHandler = self
    }
    
    public func initializeSensor(_ call: FlutterMethodCall, result: @escaping FlutterResult) -> AwareSensor? {
        if self.sensor == nil {
            if let config = call.arguments as? Dictionary<String,Any>{
                self.accelerometerSensor = AccelerometerSensor.init(AccelerometerSensor.Config(config))
            }else{
                self.accelerometerSensor = AccelerometerSensor.init(AccelerometerSensor.Config())
            }
            self.accelerometerSensor?.CONFIG.sensorObserver = self
            return self.accelerometerSensor
        }else{
            return nil
        }
    }
    
    public static func register(with registrar: FlutterPluginRegistrar) {
        let instance = SwiftAwareframeworkAccelerometerPlugin()
        // add own channel
        super.setMethodChannel(with: registrar,
                               instance: instance,
                               channelName: "awareframework_accelerometer/method");
        super.setEventChannels(with: registrar,
                               instance: instance,
                               channelNames: ["awareframework_accelerometer/event"]);

    }
    
    public func onDataChanged(data: AccelerometerData) {
        for handler in self.streamHandlers {
            if handler.eventName == "on_data_changed" {
                handler.eventSink(data.toDictionary())
            }
        }
    }
}

Eaxample App

import 'package:awareframework_core/awareframework_core.dart';

class _MyAppState extends State<MyApp> {
  
  AccelerometerSensor sensor;
  AccelerometerSensorConfig config;
    
  @override
  void initState() {
    super.initState();
    config = AccelerometerSensorConfig()
      ..debug = true
      ..label = "label";
    
    sensor = new SampleSensor(config);

  }

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
          appBar: new AppBar(
            title: const Text('Plugin Example App'),
          ),
          body: new AccelerometerCard(sensor: sensor)
      ),
    );
  }
}

Publishing the your plugin

Add author and homepage information into pubspec.yaml

author: AWARE Mobile Context Instrumentation Middleware/Framework <yuuki.nishiyama@oulu.fi>
homepage: http://www.awareframework.com

Publish

$ flutter packages pub publish --dry-run
$ flutter packages pub publish

0.0.1

  • TODO: Describe initial release.

example/README.md

awareframework_core_example

Demonstrates how to use the awareframework_core plugin.

Getting Started

For help getting started with Flutter, view our online documentation.

Use this package as a library

1. Depend on it

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


dependencies:
  awareframework_core: ^0.1.0

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:awareframework_core/awareframework_core.dart';
  
Version Uploaded Documentation Archive
0.1.0 Dec 12, 2018 Go to the documentation of awareframework_core 0.1.0 Download awareframework_core 0.1.0 archive
0.0.11 Dec 11, 2018 Go to the documentation of awareframework_core 0.0.11 Download awareframework_core 0.0.11 archive
0.0.10 Dec 3, 2018 Go to the documentation of awareframework_core 0.0.10 Download awareframework_core 0.0.10 archive
0.0.9 Nov 28, 2018 Go to the documentation of awareframework_core 0.0.9 Download awareframework_core 0.0.9 archive
0.0.8 Nov 24, 2018 Go to the documentation of awareframework_core 0.0.8 Download awareframework_core 0.0.8 archive
0.0.7 Nov 24, 2018 Go to the documentation of awareframework_core 0.0.7 Download awareframework_core 0.0.7 archive
0.0.6 Nov 23, 2018 Go to the documentation of awareframework_core 0.0.6 Download awareframework_core 0.0.6 archive
0.0.4 Nov 22, 2018 Go to the documentation of awareframework_core 0.0.4 Download awareframework_core 0.0.4 archive
0.0.3 Nov 22, 2018 Go to the documentation of awareframework_core 0.0.3 Download awareframework_core 0.0.3 archive
0.0.2 Nov 20, 2018 Go to the documentation of awareframework_core 0.0.2 Download awareframework_core 0.0.2 archive

All 11 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
54
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
77
Learn more about scoring.

We analyzed this package on Dec 12, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.7
  • Flutter: 1.0.0

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
charts_flutter ^0.5.0 0.5.0
flutter 0.0.0
Transitive dependencies
charts_common 0.5.0
collection 1.14.11
intl 0.15.7
logging 0.11.3+2
meta 1.1.6
path 1.6.2
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8