sunmi_scanner 0.0.4 sunmi_scanner: ^0.0.4 copied to clipboard
Sunmi support package that allows you to easily interface with your scanner device
import 'package:flutter/material.dart';
import 'package:sunmi_scanner/sunmi_scanner.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String? scannedValue;
void _setScannedValue(String value) {
setState(() {
scannedValue = value;
});
}
@override
void initState() {
super.initState();
SunmiScanner.onBarcodeScanned().listen((event) {
_setScannedValue(event);
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Center(
child: Text(scannedValue ?? ""),
),
],
),
),
);
}
}