tsc_blue_print

Creator: coderz1093

Last updated:

0 purchases

tsc_blue_print Image
tsc_blue_print Images
Add to Cart

Description:

tsc blue print

tsc_blue_print #
Impresión TSC Bluetooth / Network
Decripcion #
Es un plug-in package, desarrollado para flutter con compatibilidad para Android y IOS para poder interactuar con las impresoras de ticket marca TSC.
Instalar #
flutter pub add tsc_blue_print
copied to clipboard
Ejemplo #
class _MyAppState extends State<MyApp> {
String _platformVersion = 'Unknown';
final _tscBluePrintPlugin = TscBluePrint();

String device = "";
bool connected = false;
List availableBluetoothDevices = [];

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

Future<void> initPlatformState() async {
String platformVersion;
try {
platformVersion = await _tscBluePrintPlugin.getPlatformVersion() ??
'Unknown platform version';
} on PlatformException {
platformVersion = 'Failed to get platform version.';
}

if (!mounted) return;

setState(() {
_platformVersion = platformVersion;
});
}

Future<void> getBluetooth() async {
final List? bluetooths = await BluetoothThermalPrinter.getBluetooths;
print("Print $bluetooths");
setState(() {
availableBluetoothDevices = bluetooths == null ? [] : bluetooths;
});
}

Future<void> setConnect(String mac) async {
//final String? result = await BluetoothThermalPrinter.connect(mac);
device = mac;
print("state conneected $device");
setState(() {
connected = true;
});
}

Future<void> inbound() async {
String printMessage;
String idAddress = device;
print(idAddress);
try {
printMessage = await _tscBluePrintPlugin.printBlue(
ipAddress: device,
widthPaper: 47,
heightPaper: 25,
numero: '0001',
tara: "0.58",
bruto: "11.81",
peso: "11.23",
vendor: "PEC. SAN FRANCISCO(MAIZALES)",
expiryDate: '03/22/2020',
productCode: '000000001',
productName: 'HUEVO PARDO');
} on PlatformException {
printMessage = 'Failed to communcate with this printer. ';
}

print(printMessage);
}

@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Scaffold(
appBar: AppBar(
title: Text("Test de Impresion TSC",
style: TextStyle(color: Colors.brown)),
centerTitle: true,
backgroundColor: Colors.white,
iconTheme: IconThemeData(color: Colors.brown),
actions: [],
),
body: Container(
padding: EdgeInsets.all(20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text("Search Paired Bluetooth"),
TextButton(
onPressed: () {
this.getBluetooth();
},
child: Text("Search"),
),
Container(
height: 200,
child: ListView.builder(
itemCount: availableBluetoothDevices.length > 0
? availableBluetoothDevices.length
: 0,
itemBuilder: (context, index) {
return ListTile(
onTap: () {
String select = availableBluetoothDevices[index];
List list = select.split("#");
// String name = list[0];
String mac = list[1];
this.setConnect(mac);
},
title: Text('${availableBluetoothDevices[index]}'),
subtitle: Text("Click to connect"),
);
},
),
),
SizedBox(
height: 30,
),
TextButton(
onPressed: connected ? this.inbound : null,
child: Text("Print"),
),
],
),
),
),
),
);
}
}
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.