sunmi_uhf 0.0.1
sunmi_uhf: ^0.0.1 copied to clipboard
A new Flutter project.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:sunmi_uhf/sunmi_uhf.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? _result = 'Unknown';
@override
void initState() {
super.initState();
SunmiUhf.init();
SunmiUhf.onUhfScanned().listen((event) {
_result = event;
setState(() {});
});
}
@override
void dispose() {
SunmiUhf.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Sunmi uhf'),
),
body: Center(
child: Text('Scan result: $_result\n'),
),
floatingActionButton: FloatingActionButton(
child: const Icon(Icons.scanner),
onPressed: (){
SunmiUhf.scan();
},
),
),
);
}
}