uhf_plugin 1.0.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 64

uhf_plugin #

A flutter plugin for Tablet Alps ax6737 to read UHF Cards.

https://pub.dev/packages/uhf_plugin

Getting Started #

In your Gradle exclude Flutter so files because libary is working in 32bit mode
Only use release apk because running from IDE will not exclude 64bit files
`packagingOptions {
    exclude 'lib/arm64-v8a/libflutter.so'
    exclude 'lib/arm64-v8a/libapp.so'
}`
  • Import the library: import 'package:uhf_plugin/uhf_plugin.dart';

  • Open connection to the UHF reader

    await UhfPlugin.connect

  • Check if is the reader connected

    await UhfPlugin.isConnected;

  • Start reading data

    await UhfPlugin.start;

  • Is started reading

    await UhfPlugin.isStarted;

  • Stop Reading

    await UhfPlugin.stop;

  • Close the connection

    await UhfPlugin.close;

  • Clear cached data for the reader

    await UhfPlugin.clearData;

  • Is Empty Tags

    await UhfPlugin.isEmptyTags;

  • Listen to connection status

    UhfPlugin.connectedStatusStream.receiveBroadcastStream().listen(updateIsConnected); updateIsConnected should listen to bool value

  • Listen to tags status

    UhfPlugin.tagsStatusStream.receiveBroadcastStream().listen(updateTags);

        List<TagEpc> _data = [];
        void updateTags(dynamic result) {
         setState(() {
             _data = TagEpc.parseTags(result);
          });
        }
    

    alt text

1.0.3 #

  • Minor gradle fix

1.0.2 #

  • Fix null exception

1.0.1 #

  • Added TagEpc object instead of string

1.0.0 #

  • Added Documentation

0.0.1 #

  • Describe initial release.

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:uhf_plugin/uhf_plugin.dart';
import 'package:uhf_plugin/tag_epc.dart';

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

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

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';
  bool _isStarted = false;
  bool _isEmptyTags = false;
  bool _isConnected = false;

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

  // 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 UhfPlugin.platformVersion;
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }
    UhfPlugin.connectedStatusStream
        .receiveBroadcastStream()
        .listen(updateIsConnected);
    UhfPlugin.tagsStatusStream.receiveBroadcastStream().listen(updateTags);

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

  List<TagEpc> _data = [];
  void updateTags(dynamic result) {
    setState(() {
    _data = TagEpc.parseTags(result);
    });
  }

  void updateIsConnected(dynamic isConnected) {
    //setState(() {
    _isConnected = isConnected;
    //});
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            children: <Widget>[
              Text('Running on: $_platformVersion'),
              RaisedButton(
                  child: Text('Call connect'),
                  onPressed: () async {
                    await UhfPlugin.connect;
                  }),
              RaisedButton(
                  child: Text('Call is Connected'),
                  onPressed: () async {
                    bool isConnected = await UhfPlugin.isConnected;
                    setState(() {
                      this._isConnected = isConnected;
                    });
                  }),
              RaisedButton(
                  child: Text('Call isStarted'),
                  onPressed: () async {
                    bool isStarted = await UhfPlugin.isStarted;
                    setState(() {
                      this._isStarted = isStarted;
                    });
                  }),
              Text('UHF Reader isStarted:$_isStarted'),
              RaisedButton(
                  child: Text('Call Start'),
                  onPressed: () async {
                    await UhfPlugin.start;
                  }),
              RaisedButton(
                  child: Text('Call Stop'),
                  onPressed: () async {
                    await UhfPlugin.stop;
                  }),
              RaisedButton(
                  child: Text('Call Close'),
                  onPressed: () async {
                    await UhfPlugin.close;
                  }),
              RaisedButton(
                  child: Text('Call Clear Data'),
                  onPressed: () async {
                    await UhfPlugin.clearData;
                  }),
              RaisedButton(
                  child: Text('Call is Empty Tags'),
                  onPressed: () async {
                    bool isEmptyTags = await UhfPlugin.isEmptyTags;
                    setState(() {
                      this._isEmptyTags = isEmptyTags;
                    });
                  }),
              Text('UHF Reader isEmptyTags:$_isEmptyTags'),
              Text('UHF Reader isConnected:$_isConnected'),
              ..._data.map((TagEpc tag) => Text('UHF Tag - Count:${tag.count} EPC:${tag.epc}')),
            ],
          ),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  uhf_plugin: ^1.0.3

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:uhf_plugin/uhf_plugin.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
30
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
98
Overall:
Weighted score of the above. [more]
64
Learn more about scoring.

We analyzed this package on Jul 8, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because of import path [package:uhf_plugin/uhf_plugin.dart] that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because of import path [package:uhf_plugin/uhf_plugin.dart] that declares support for platforms: android, ios

Package does not support Flutter platform web

Because of import path [package:uhf_plugin/uhf_plugin.dart] that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because of import path [package:uhf_plugin/uhf_plugin.dart] that declares support for platforms: android, ios

Package not compatible with SDK dart

because of import path [uhf_plugin] that is in a package requiring null.

Health issues and suggestions

Document public APIs. (-1 points)

24 out of 24 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/tag_epc.dart.

Run flutter format to format lib/tag_epc.dart.

Maintenance suggestions

The package description is too short. (-2 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.1
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
flutter_test