proximity_plugin 0.0.1 copy "proximity_plugin: ^0.0.1" to clipboard
proximity_plugin: ^0.0.1 copied to clipboard

outdatedDart 1 only

A new flutter plugin project.

example/lib/main.dart

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


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

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

class _MyAppState extends State<MyApp> {
  List<double> _proximity ;
  List<StreamSubscription<dynamic>> _streamSubscriptions =
  <StreamSubscription<dynamic>>[];
  @override
  initState() {
    super.initState();
    initPlatformState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  initPlatformState() async {
    _streamSubscriptions
        .add(proximityEvents.listen((ProximityEvent event) {
      setState(() {
        _proximity= <double>[event.x];
      });
    }));
  }

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text('Plugin example app'),
        ),
        body: new Center(
          child: new Text('Proximity is: ${_proximity}\n'),
        ),
      ),
    );
  }
}
0
likes
15
pub points
31%
popularity

Publisher

unverified uploader

A new flutter plugin project.

Homepage

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on proximity_plugin