barcode_plugin 1.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 67

barcode_plugin #

A flutter plugin for Tablet Alps ax6737 to read barcode.

https://pub.dev/packages/barcode_plugin/

Getting Started #

In your Android Manifest add the following in application tag
    <service android:name="com.scan.service.ScanService">
    <intent-filter>
            <action android:name="com.scan.service" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </service>
    <service android:name="com.scan.service.Scan1DService">
        <intent-filter>
            <action android:name="com.scan.service" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </service>
    <receiver android:name="com.scan.service.BootReceiver">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
        </intent-filter>
    </receiver>
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
```ruby
packagingOptions {
    exclude 'lib/arm64-v8a/libflutter.so'
    exclude 'lib/arm64-v8a/libapp.so'
    exclude 'lib/arm64-v8a/libvudroid.so'
    exclude 'lib/armeabi/libvudroid.so'
    exclude 'lib/mips/libvudroid.so'
    exclude 'lib/x86/libvudroid.so'
    pickFirst 'lib/armeabi-v7a/libdevapi.so'//In case a library conflict with other libs
    }
```
  • Import the library: import 'package:barcode_plugin/barcode_plugin.dart';

  • Open connection to the barcode reader

    await BarcodePlugin.open;

  • Check if connection is opened

    await BarcodePlugin.isOpen;

  • Start scanning barcode labels

    await BarcodePlugin.startScanning;

  • Close connection to the barcode reader

    await BarcodePlugin.close;

  • Listen to scanner connection status

    BarcodePlugin.scannerStatusStream.receiveBroadcastStream().listen(updateData);

  • Listen to barcode labels

    BarcodePlugin.barcodeStatusStream.receiveBroadcastStream().listen(updateData);

1.0.1 #

  • update readme with the required tags in Android manifest.

1.0.0 #

  • Cleaning up.

0.0.2 #

  • update readme.

0.0.1 #

  • initial release.

example/lib/main.dart

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

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

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

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

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';
  bool _isOpen = 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 BarcodePlugin.platformVersion;
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }
    BarcodePlugin.scannerStatusStream.receiveBroadcastStream().listen(updateData);
    BarcodePlugin.barcodeStatusStream.receiveBroadcastStream().listen(updateData);

    // 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<String> _data = ['--'];
  void updateData(dynamic  result) {
    setState(() {
      _data.add('$result');
    });
  }

  @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 isOpen'),
                  onPressed: () async {
                    bool isOpen = await BarcodePlugin.isOpen;
                    setState(() {
                      this._isOpen = isOpen;
                    });
                  }),
              Text('Barcode Scanner isOpen:$_isOpen'),
              RaisedButton(
                  child: Text('Call Open'),
                  onPressed: () async {
                    await BarcodePlugin.open;
                    bool isOpen = await BarcodePlugin.isOpen;
                    setState(() {
                      this._isOpen = isOpen;
                    });
                  }),
              RaisedButton(
                  child: Text('Call Close'),
                  onPressed: () async {
                    await BarcodePlugin.close;
                    bool isOpen = await BarcodePlugin.isOpen;
                    setState(() {
                      this._isOpen = isOpen;
                    });
                  }),
              RaisedButton(
                  child: Text('Call Start Scanning'),
                  onPressed: () async {
                    await BarcodePlugin.startScanning;
                    bool isOpen = await BarcodePlugin.isOpen;
                    setState(() {
                      this._isOpen = isOpen;
                    });
                  }),
              ..._data.map((text) =>Text('Status - Barcode: $text')),
            ],
          ),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  barcode_plugin: ^1.0.1

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:barcode_plugin/barcode_plugin.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
33
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
67
Learn more about scoring.

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

  • Dart: 2.8.1
  • pana: 0.13.8-dev
  • Flutter: 1.17.0

Health suggestions

Format lib/generated/i18n.dart.

Run flutter format to format lib/generated/i18n.dart.

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
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test