Aware Core

Build Status

A Core Plugin for Aware Framework on Flutter

Developing Aware Plugin for Flutter


  1. Make a template app using flutter command
$ flutter create --org com.awareframework.accelerometer --template=plugin --platforms=android,ios -i swift -a kotlin awareframework_accelerometer
  1. Add the awareframework_core into your pubspec.yaml

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.init(AccelerometerSensorConfig config) : super.init(config){

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

  void cancelAllEventChannels() {


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

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


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



  1. Add following code into ios/awareframework_accelerometer.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.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))
                self.accelerometerSensor = AccelerometerSensor.init(AccelerometerSensor.Config())
            self.accelerometerSensor?.CONFIG.sensorObserver = self
            return self.accelerometerSensor
            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" {

Eaxample App

import 'package:awareframework_core/awareframework_core.dart';

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


  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 <>


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