pda_608_plugin 0.0.7
pda_608_plugin: ^0.0.7 copied to clipboard
A plugin for PDA608 hardware
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:pda_608_plugin/pda_608_plugin.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 _scanResult = 'No barcode scanned yet';
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('PDA608 Plugin Example'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Scan Result: $_scanResult'),
const SizedBox(height: 20),
ElevatedButton(
onPressed: _scanBarcode,
child: const Text('Scan Barcode'),
),
],
),
),
),
);
}
Future<void> _scanBarcode() async {
try {
final String? result = await Pda608Plugin.scanBarcode();
setState(() {
_scanResult = result ?? 'Scan failed or was cancelled';
});
} catch (e) {
setState(() {
_scanResult = 'Error: $e';
});
}
}
}