toughpad 0.0.1 toughpad: ^0.0.1 copied to clipboard
Panasonic Toughpad plugin.
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 = 'Unknown';
@override
void initState() {
super.initState();
initPlatformState();
}
Future<void> initPlatformState() async {
String platformVersion;
if (!mounted) return;
Toughpad.init();
setState(() {
_barcode = platformVersion;
});
Toughpad.readBarcodes.stream.listen((message)=>{
setState(() {
_barcode = message;
})
});
}
@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"),
),
Text('Barcode: $_barcode\n'),
new RaisedButton(
onPressed: ()=> Toughpad.stopBarcodeScan(),
textColor: Colors.white,
color: Colors.red,
padding: const EdgeInsets.all(8.0),
child: new Text("Stop"),
),
],
)//,
),
),
);
}
}