PDA 608 Plugin A Flutter plugin for QS608 PDA devices with thermal printing and barcode scanning capabilities.

Features Barcode Scanning: Trigger the built-in scanner and receive scan results Thermal Printing: Print text, barcodes, QR codes, and images Paper Control: Support for both continuous thermal paper and gap label paper Android Only: This plugin only supports Android PDA devices with thermal printing and scanning capabilities Getting Started Installation Add this to your package's pubspec.yaml file:

yaml

Copy dependencies: pda_608_plugin: ^0.0.1 Android Setup Ensure the following permissions are added to your Android project's AndroidManifest.xml:

xml

Copy

dart

Copy bool initialized = await Pda608Plugin.init(); Barcode Scanning Trigger the scanner and listen for results:

dart

Copy // Set up listener for scan results Pda608Plugin.scanResults.listen((result) { print('Scanned: ${result.text}'); print('Timestamp: ${result.timestamp}'); });

// Trigger the scanner await Pda608Plugin.startScan(); Printing Text dart

Copy await Pda608Plugin.printText( text: 'Hello World!', size: 1, // 1 = normal, 2 = double size align: 1, // 0 = left, 1 = center, 2 = right paperWidth: 52, // 52 = 58mm paper, 80 = 80mm paper isLabel: false, // true for gap label paper tear: true, // feed extra paper for tearing ); Printing Barcode dart

Copy await Pda608Plugin.printBarcode( data: '1234567890', width: 380, height: 100, showText: true, fontSize: 16, align: 1, paperWidth: 52, isLabel: false, tear: true, ); Printing QR Code dart

Copy await Pda608Plugin.printQrCode( data: 'https://flutter.cn', width: 200, height: 200, showText: true, fontSize: 16, align: 1, paperWidth: 52, isLabel: false, tear: true, ); Setting Label Mode Enable or disable label mode for gap label paper:

dart

Copy // Enable label mode for gap label paper await Pda608Plugin.setLabelMode(true);

// Disable label mode for continuous thermal paper await Pda608Plugin.setLabelMode(false); Clean Up When finished with the plugin, close it properly:

dart

Copy await Pda608Plugin.close(); Complete Example dart

Copy 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

class _MyAppState extends State

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

Future

  if (initialized) {
    Pda608Plugin.scanResults.listen((result) {
      setState(() {
        _scanResult = result.text;
      });
    });
  }
} catch (e) {
  print('Failed to initialize plugin: $e');
}

}

@override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( title: const Text('PDA 608 Plugin Example'), ), body: SingleChildScrollView( child: Padding( padding: const EdgeInsets.all(16.0), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Text('Plugin initialized: $_initialized'), const SizedBox(height: 20),

            // Scanner section
            const Text('Scanner', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
            Text('Scan result: $_scanResult'),
            ElevatedButton(
              onPressed: _initialized ? () => Pda608Plugin.startScan() : null,
              child: const Text('Start Scan'),
            ),
            const SizedBox(height: 20),

            // Printer section
            const Text('Printer', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
            TextField(
              controller: _textController,
              decoration: const InputDecoration(labelText: 'Text to print'),
              minLines: 3,
              maxLines: 10,
            ),
            const SizedBox(height: 10),
            ElevatedButton(
              onPressed: _initialized ? () => Pda608Plugin.printText(text: _textController.text) : null,
              child: const Text('Print Text'),
            ),
          ],
        ),
      ),
    ),
  ),
);

}

@override void dispose() { _textController.dispose(); Pda608Plugin.close(); super.dispose(); } } Troubleshooting Scanner Not Working Ensure the hardware is properly initialized Check that permissions are properly set Verify that the app is in focus when scanning Printer Not Working Check if paper is loaded correctly Verify printer is not overheated For label paper, ensure the correct label mode is set License This project is licensed under the MIT License - see the LICENSE file for details.