zebra_rfid_sdk_plugin 0.0.3 copy "zebra_rfid_sdk_plugin: ^0.0.3" to clipboard
zebra_rfid_sdk_plugin: ^0.0.3 copied to clipboard

Zebra Rfid Sdk Plugin.

Zebra Rfid SDK Plugin #

Steps to follow #

  1. flutter pub add zebra_rfid_sdk_plugin
  2. create/add folder to android
  • create android/RFIDAPI3Library folder

  • download content from below link and copy in android/RFIDAPI3Library

    Note:- (build.gradle and RFIDAPI3Library.arr add this files to android/RFIDAPI3Library) Link

  1. In setting.gradle add below lines.
  • include ':app',':RFIDAPI3Library' //RFIDAPI3Library is folder name
  1. In build.gradle add below lines. // app level (android/app/build.gradle)
  • dependencies { implementation project(":RFIDAPI3Library",) } //RFIDAPI3Library is folder name

    see here -> link

  1. Add below line to Android.xml
  • xmlns:tools="http://schemas.android.com/tools" (this will under manifest tag)
  • tools:replace="android:label" (this will add under application tag)
  1. minSdkVersion 19 or higher

Examples #

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:zebra_rfid_sdk_plugin/zebra_event_handler.dart';
import 'package:zebra_rfid_sdk_plugin/zebra_rfid_sdk_plugin.dart';

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

class MyApp extends StatefulWidget {
  const MyApp({super.key});

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

class _MyAppState extends State<MyApp> {
  String? _platformVersion = 'Unknown';
  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  Map<String?, RfidData> rfidDatas = {};
  ReaderConnectionStatus connectionStatus = ReaderConnectionStatus.UnConnection;
  addDatas(List<RfidData> datas) async {
    for (var item in datas) {
      var data = rfidDatas[item.tagID];
      if (data != null) {
        if (data.count == null) data.count = 0;
        data.count = data.count + 1;
        data.peakRSSI = item.peakRSSI;
        data.relativeDistance = item.relativeDistance;
      } else
        rfidDatas.addAll({item.tagID: item});
    }
    setState(() {});
  }

  // 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 ZebraRfidSdkPlugin.platformVersion;
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }
    if (!mounted) return;

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        home: Scaffold(
      appBar: AppBar(
        title: Text('Status  ${connectionStatus.index}'),
      ),
      body: Center(
          child: Column(
        children: [
          Text('Running on: $_platformVersion\n'),
          Text('count:${rfidDatas.length.toString()}'),
          const SizedBox(height: 20),
          Row(mainAxisAlignment: MainAxisAlignment.spaceAround, children: [
            ElevatedButton(
              onPressed: () async {
                ZebraRfidSdkPlugin.setEventHandler(ZebraEngineEventHandler(
                  readRfidCallback: (datas) async {
                    addDatas(datas);
                  },
                  errorCallback: (err) {
                    ZebraRfidSdkPlugin.toast(err.errorMessage);
                  },
                  connectionStatusCallback: (status) {
                    setState(() {
                      connectionStatus = status;
                    });
                  },
                ));
                ZebraRfidSdkPlugin.connect();
              },
              child: const Text("read"),
            ),
            ElevatedButton(
              onPressed: () async {
                setState(() {
                  rfidDatas = {};
                });
              },
              child: const Text("clear"),
            ),
            ElevatedButton(
              onPressed: () async {
                ZebraRfidSdkPlugin.disconnect();
              },
              child: const Text("stop"),
            ),
          ]),
          Expanded(
              child: Scrollbar(
            child: ListView.builder(
              itemBuilder: (context, index) {
                var key = rfidDatas.keys.toList()[index];
                return ListTile(title: Text(rfidDatas[key]?.tagID ?? 'null'));
              },
              itemCount: rfidDatas.length,
            ),
          ))
        ],
      )),
    ));
  }
}
}

Tested on Zebra MC33 Device #

Authors #

Badges #

MIT License GPLv3 License AGPL License

Support #

For support, give a star ⭐ to repo.

6
likes
105
points
105
downloads

Publisher

unverified uploader

Weekly Downloads

Zebra Rfid Sdk Plugin.

Repository (GitHub)

Documentation

API reference

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on zebra_rfid_sdk_plugin