toughpad 1.0.1

Flutter Android iOS

Panasonic Toughpad plugin.

example/lib/main.dart

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

import 'package:toughpad/toughpad.dart';

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

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

class _MyAppState extends State<MyApp> {
  String _barcode = '';
  String _button = '';

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

  Future<void> initPlatformState() async {
    if (!mounted) return;

    Toughpad.readBarcodes.stream.listen((message) {
      setState(() {
        print(message);
        _barcode = message;
      });
    });

    Toughpad.buttonEvents.stream.listen((message) {
      setState(() {
        _button = message;
      });
    });

    await Toughpad.init();
    var hardware = await Toughpad.hardwareExists.first;
    setState(() {
      _barcode = hardware.toString();
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
            child: new Row(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          children: <Widget>[
            new RaisedButton(
              padding: const EdgeInsets.all(8.0),
              textColor: Colors.white,
              color: Colors.blue,
              onPressed: () => Toughpad.startBarcodeScan(),
              child: new Text("Start"),
            ),
            Column(
              children: <Widget>[
                Text('Barcode: $_barcode\n'),
                Text('Button: $_button\n'),
              ],
            ),
            new RaisedButton(
              onPressed: () => Toughpad.stopBarcodeScan(),
              textColor: Colors.white,
              color: Colors.red,
              padding: const EdgeInsets.all(8.0),
              child: new Text("Stop"),
            ),
          ],
        ) //,
            ),
      ),
    );
  }
}
0
likes
70
pub points
0%
popularity

Panasonic Toughpad plugin.

Homepage

Documentation

API reference

Uploader

andrewmacaulay@gmail.com

License

unknown (LICENSE)

Dependencies

flutter, rxdart

More

Packages that depend on toughpad