flutter_xprinter_tspl_sdk 0.0.1 copy "flutter_xprinter_tspl_sdk: ^0.0.1" to clipboard
flutter_xprinter_tspl_sdk: ^0.0.1 copied to clipboard

PlatformWindows

Flutter Windows plugin for XPrinter TSPL/TSPL2 label printers, with builders for text, barcodes, QR codes, and raw TSPL commands over USB, TCP, and serial.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_xprinter_tspl_sdk/flutter_xprinter_tspl_sdk.dart';

void main() {
  runApp(const ExampleApp());
}

class ExampleApp extends StatefulWidget {
  const ExampleApp({super.key});

  @override
  State<ExampleApp> createState() => _ExampleAppState();
}

class _ExampleAppState extends State<ExampleApp> {
  String _status = 'Ready';

  Future<void> _printTestLabel() async {
    setState(() => _status = 'Printing...');
    try {
      await TsplConnection.connect(
        type: XprinterTsplConnectionType.usb,
        address: '',
      );
      await TsplPrinter.setup(labelWidthMm: 58, labelHeightMm: 40);
      await TsplPrinter.clearBuffer();
      await TsplPrinter.text(x: 30, y: 30, text: 'BILLZ TSPL USB');
      await TsplPrinter.barcode(x: 30, y: 80, content: '1234567890');
      await TsplPrinter.qrCode(x: 330, y: 40, content: 'https://billz.ai');
      await TsplPrinter.print();
      await TsplConnection.disconnect();
      setState(() => _status = 'Printed');
    } catch (e) {
      setState(() => _status = e.toString());
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('XPrinter TSPL SDK')),
        body: Padding(
          padding: const EdgeInsets.all(16),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: [
              FilledButton(
                onPressed: _printTestLabel,
                child: const Text('Print USB Test Label'),
              ),
              const SizedBox(height: 12),
              Text(_status),
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
140
points
24
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Flutter Windows plugin for XPrinter TSPL/TSPL2 label printers, with builders for text, barcodes, QR codes, and raw TSPL commands over USB, TCP, and serial.

Topics

#printing #printer #tspl #labels #windows

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_xprinter_tspl_sdk

Packages that implement flutter_xprinter_tspl_sdk