zebra_datawedge 0.1.3 copy "zebra_datawedge: ^0.1.3" to clipboard
zebra_datawedge: ^0.1.3 copied to clipboard

PlatformAndroid

Support hardware scanner for Zebra devices (ET5X) to receive intent and parse it into readable data.

example/lib/main.dart

import 'dart:convert';

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

import 'package:zebra_datawedge/zebra_datawedge.dart';

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

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  MyAppState createState() => MyAppState();
}

class MyAppState extends State<MyApp> {
  String _data = "waiting...";
  String _labelType = "waiting...";
  String _source = "waiting...";

  @override
  void initState() {
    super.initState();
    initDataWedgeListener();
  }

  // create a listener for data wedge package
  Future<void> initDataWedgeListener() async {
    ZebraDataWedge.listenForDataWedgeEvent((response) {
      if (response != null && response is String) {
        setState(() {
          Map<String, dynamic>? jsonResponse;
          try {
            jsonResponse = json.decode(response);
          } catch (e) {
            //TODO handling
          }
          if (jsonResponse != null) {
            _data = jsonResponse["decodedData"];
            _labelType = jsonResponse["decodedLabelType"];
            _source = jsonResponse["decodedSource"];
          } else {
            _source = "An error occured";
          }
        });
      }
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('DataWedgeIntent Example'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            mainAxisSize: MainAxisSize.min,
            children: [
              Text("Label Type: $_labelType"),
              Text("Soruce: $_source"),
              Text("Data: $_data")
            ],
          ),
        ),
      ),
    );
  }
}
10
likes
160
pub points
76%
popularity

Publisher

verified publisherbuildtoapp.com

Support hardware scanner for Zebra devices (ET5X) to receive intent and parse it into readable data.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on zebra_datawedge