starxpandprinter 0.0.3 starxpandprinter: ^0.0.3 copied to clipboard
StarXpandPrinter
example/lib/main.dart
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:starxpandprinter/starxpand.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
List<StarXpandPrinter>? printers;
@override
void initState() {
super.initState();
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> _find() async {
var ps = await StarXpand.findPrinters(
interfaces: [StarXpandInterface.bluetooth]);
setState(() {
printers = ps;
});
}
_openDrawer(StarXpandPrinter printer) {
StarXpand.openDrawer(printer);
}
_startInputListener(StarXpandPrinter printer) {
StarXpand.startInputListener(
printer, (p) => print('_startInputListener: ${p.inputString}'));
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Column(children: [
TextButton(child: Text('FInd'), onPressed: () => _find()),
if (printers != null)
for (var p in printers!)
ListTile(
onTap: () => _printTest(p),
title: Text(p.model.label),
subtitle: Text(p.identifier),
trailing: Text(p.interface.name))
]),
),
);
}
_printTest(StarXpandPrinter printer) async {
await StarXpand.imprimir(
texto: texto, asistencia: true, reimpresion: false);
await StarXpand.imprimir(texto: texto, asistencia: true, reimpresion: true);
}
}
const String texto =
" Star Clothing Boutique\n 123 Star Road\n City, State 12345\n\nDate:MM/DD/YYYY Time:HH:MM PM\n--------------------------------------\nSALE\nSKU Description Total\n300678566 PLAIN T-SHIRT 10.99\n300692003 BLACK DENIM 29.99\n300651148 BLUE DENIM 29.99\n300642980 STRIPED DRESS 49.99\n30063847 BLACK BOOTS 35.99\n\nSubtotal 156.95\nTax 0.00\n--------------------------------------\nTotal 156.95\n--------------------------------------\n\nCharge\n156.95\nVisa XXXX-XXXX-XXXX-0123\nRefunds and Exchanges\nWithin 30 days with receipt\nAnd tags attached\n";