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

outdated

A new Flutter Plugin to Connect any Android Device to Zebra Bluetooth Scanner

example/lib/main.dart

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

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

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

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

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

  static const platform = const MethodChannel('com.pratap.zebrascanner/zebra');

  static const _stream =
  const EventChannel('com.pratap.zebrascanner/zebraevents');




  dynamic map;
  StreamSubscription subscription;

  var eventData="";

  @override
  void initState() {
    super.initState();
    initPlatformState();

    subscription = _stream.receiveBroadcastStream().listen((barcodeData) {
      setState(() {
        map = barcodeData;

        print(map);

        var _list = map.values.toList();

        // Barcode
        print(_list[0]);
        // BarcodeType
        print(_list[1]);

        // ScannerId
        print(_list[2]);

        eventData = _list[0];

        //eventData = map;

      });
    });


  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      platformVersion = await Zebrascanner.platformVersion;
    } 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;
    });
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> openBarcodeScreen() async {
    String result;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      result = await Zebrascanner.barcodeScreen;
    } on PlatformException {
      result = 'Failed.';
    }


  }


  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Zebra Bluetooth Scanner app'),
        ),
        body: Center(
          child: Container(
            child: Column(

              children: [

                SizedBox(height: 10,),

                Text('Running on: $_platformVersion\n'),

                SizedBox(height: 10,),

                FlatButton(onPressed: (){

                  openBarcodeScreen();

                }, child: Text("Barcode Screen")),

                SizedBox(height: 10,),


                Text('Running on: $eventData'),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
3
likes
0
points
3
downloads

Publisher

unverified uploader

Weekly Downloads

A new Flutter Plugin to Connect any Android Device to Zebra Bluetooth Scanner

Homepage

License

unknown (license)

Dependencies

flutter

More

Packages that depend on zebrascanner

Packages that implement zebrascanner