ibox_pro_sdk_external 0.0.5 copy "ibox_pro_sdk_external: ^0.0.5" to clipboard
ibox_pro_sdk_external: ^0.0.5 copied to clipboard

discontinued

A new flutter plugin project.

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:ibox_pro_sdk_external/ibox_pro_sdk_external.dart';

void main() {
  runApp(MyApp());
}

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

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

  @override
  void initState() {
    super.initState();
    //enable2can();
    //enable2can().whenComplete(() => auth()).whenComplete(() => attachCard());
    //auth().then((value) => attachCard());
    //attachCard();

    Stream<String> myStream = IboxProSdkExternal.getReaderEventStream;
    StreamSubscription subscription = myStream.listen((data) {
      print('2can DATA : $data');
    }, onError: (err) {
      print('2can ERROR');
    });

    // Stream<String> myStream2 = IboxProSdkExternal.getBatteryStateEventStream;
    // subscription = myStream2.listen((data) {
    //   print('2can battery : $data');
    // }, onError: (err) {
    //   print('2can battery ERROR');
    // });
  }

  Future<void> auth() async {
    //await IboxProSdkExternal.auth("meb.int@inbox.ru", "9630773739");
    await IboxProSdkExternal.auth("Kiox@agent.demo", "12345678");
  }

  Future<void> attachCard() async {
    await IboxProSdkExternal.attachCard;
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> enable2can() async {
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      //platformVersion = await IboxProSdkExternal.platformVersion;
      await IboxProSdkExternal.enable2can;
//
//      Stream<String> myStream = IboxProSdkExternal.getIboxStream;
//
//      StreamSubscription subscription = myStream.listen((data) {
//        print('2can DATA : $data');
//      },
//      onError: (err){
//        print('2can ERROR');
//      });

//      IboxProSdkExternal sdk = new IboxProSdkExternal();
//      sdk.enable2can();

    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

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

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: new Center(
          child: Column(
            children: [
              //Text('Running on: $_platformVersion\n'),
              StreamBuilder(
                stream: IboxProSdkExternal.getReaderEventStream,
                builder:
                    (BuildContext context, AsyncSnapshot<String> snapshot) {
                  if (snapshot.hasData) {
                    return Text('OnReaderEvent: ${snapshot.data}');
                  }
                  return Text('CONNECTION: NO DATA');
                },
              ),
              StreamBuilder(
                stream: IboxProSdkExternal.getBatteryStateEventStream,
                builder:
                    (BuildContext context, AsyncSnapshot<double> snapshot) {
                  if (snapshot.hasData) {
                    return Text('Battery: ${snapshot.data}%');
                  }
                  return Text('Battery: NO DATA');
                },
              ),
              StreamBuilder(
                stream: IboxProSdkExternal.getErrorEventStream,
                builder:
                    (BuildContext context, AsyncSnapshot<String> snapshot) {
                  if (snapshot.hasData) {
                    return Text('OnErrorEvent: ${snapshot.data}');
                  }
                  if (snapshot.hasError){
                    return Text('OnErrorEvent: ${snapshot.error}');
                  }
                  return Text('OnErrorEvent: NO ERROR');
                },
              ),
              ButtonBar(
                children: [RaisedButton(
                  onPressed: enable2can,
                    child: const Text('Enable 2can'),
                ),
                RaisedButton(
                  onPressed: auth,
                  child: const Text('auth'),
                ),
                  RaisedButton(
                    onPressed: attachCard,
                    child: const Text('attachCard'),
                  )
                ],
              )
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
30
pub points
0%
popularity

Publisher

unverified uploader

A new flutter plugin project.

Repository (GitHub)
View/report issues

License

Apache-2.0 (LICENSE)

Dependencies

flutter

More

Packages that depend on ibox_pro_sdk_external