bx_btprinter

Creator: coderz1093

Last updated:

0 purchases

bx_btprinter Image
bx_btprinter Images

Languages

Categories

Add to Cart

Description:

bx btprinter

bx_btprinter #
This plugin enables receipt printing on Bixolon Bluetooth printers. It has been tested with the Bixolon SPP-R310 printer and supports Bixolon's Bluetooth mobile printers. Additionally, it only supports the Korean character set for printing.
Getting Started #
To use btPrinter in your Flutter project, add it to your pubspec.yaml:
dependencies:
bx_btprinter: ^0.0.5 # Replace with the latest version
copied to clipboard
Usage #
1. Requesting Bluetooth Permissions
Future<void> requestBluetoothPermissions() async {
final _btprinterPlugin = Btprinter();
String? result;
try {
result = await _btprinterPlugin.getBtPermission();
} on PlatformException catch (e) {
result = 'Error: ${e.message}';
}
print(result); // Prints "success" if permissions are granted
}

copied to clipboard
2. Retrieving Paired Devices
Future<void> getPairedDevices() async {
final _btprinterPlugin = Btprinter();
List<String?> devices = [];
try {
List<Object?> result = await _btprinterPlugin.getPairedDevices();
devices = result.cast<String>().where((device) => device.startsWith('SPP')).toList();
} on PlatformException catch (e) {
print('Error: ${e.message}');
}
print(devices); // Prints the list of paired devices
}
copied to clipboard
3. Printing Text
Future<void> print(String device) async {
final _btprinterPlugin = Btprinter();

List<String> deviceInfo = device!.split('(');
String logicalName = deviceInfo[0].split("_")[0].trim();
String address = deviceInfo[1].replaceAll(')', '').trim();

List<Map<String, dynamic>> textRequests = [
{
'text': 'Print Title Test\n',
'textAlignment': Btprinter.ALIGNMENT_CENTER,
'textAttribute': Btprinter.ATTRIBUTE_BOLD,
'textSize': 2,
},
{
'text': 'Print Content Test\n\n',
'textAlignment': Btprinter.ALIGNMENT_LEFT,
'textAttribute': Btprinter.ATTRIBUTE_NORMAL,
'textSize': 1,
},
];

String? result;
try {
result = await _btprinterPlugin.printText(textRequests, logicalName, address);
} on PlatformException catch (e) {
result = 'Error: ${e.message}';
}
print(result); // Prints "success" if printing is successful
}
copied to clipboard
4. Printing Barcode
Future<void> print(String device) async {
final _btprinterPlugin = Btprinter();

List<String> deviceInfo = device!.split('(');
String logicalName = deviceInfo[0].split("_")[0].trim();
String address = deviceInfo[1].replaceAll(')', '').trim();

List<Map<String, dynamic>> barcodeRequests = [
{
'data': '123456789012\n',
'symbology': Btprinter.BARCODE_TYPE_ITF, //Optional, default value
'width': 3, // Optional, default value
'height': 100, // Optional, default value
'alignment': Btprinter.ALIGNMENT_LEFT, //Optional, default value
'hri': Btprinter.BARCODE_HRI_BELOW, //Optional, default value
},
];

String? result;
try {
result = await _btprinterPlugin.printBarcode(barcodeRequests, logicalName, address);
} on PlatformException catch (e) {
result = 'Error: ${e.message}';
}
print(result); // Prints "success" if printing is successful
}
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.