/flutter_datawedge

🦓 A Flutter plugin communicate with Zebra DataWedge scanners

Primary LanguageKotlinMIT LicenseMIT

flutter_datawedge

pub package

A Flutter package to communicate with Zebra DataWedge scanners.

Getting Started

Add flutter_datawedge to your project

    dart pub add flutter_datawedge

You can access DataWedge through the singleton

    var dataWedge = FlutterDataWedge.instance;

If you don't have a profile for your app, you can use

    await FlutterDataWedge.instance.createProfile("MyProfile",autoActivate: true);

If you want to make further adjustments to your profile you can use setConfig

    var config = ProfileConfig(
        profileName: "MyProfile",
        profileEnabled: true,
        configMode: ConfigMode.update,
        barcodeParamters: PluginBarcodeParamters(
            scannerSelection: ScannerIdentifer.auto,
            enableHardwareTrigger: true,
            enableAimMode: false,
        )
    );
  await FlutterDataWedge.instance.setConfig(config);

The parameter auto activate will configure your profile to automatically activate when your application is in the foreground and enables intent output to receive scans.

You can then simply listen for barcodes:

    var scanSub = FlutterDataWedge.instance.scans.listen((event) {
      // Do something with a ScanEvent
      print(event.dataString);
    });

    // later

    scanSub.cancel()

To receive the current status of the scanner you will have to register for notifications

    await FlutterDataWedge.instance.registerForNotifications();

You can then listen on the stream of events

     FlutterDataWedge.instance.status.listen(....)

Controlling the scanner

    await FlutterDataWedge.instance.suspendPlugin(); // Temporarily suspend scanning
    await FlutterDataWedge.instance.resumePlugin(); // Resume after suspending
    await FlutterDataWedge.instance.enablePlugin(); // Enable dw
    await FlutterDataWedge.instance.disablePlugin(); // Disable dw

You can also create a soft trigger:

    FlutterDataWedge.instance.softScanTrigger(true); // Starts scanning
    ...
    FlutterDataWedge.instance.softScanTrigger(false); // Stops scanning

Acknowledgements

The package was started by rafaeljustinox and and contains contributions by LenhartStephan. It is now maintained by Circus Kitchens.