The bt-thermal package is a Flutter package designed to facilitate the integration of Bluetooth thermal printers into Flutter applications. It provides functionalities for scanning Bluetooth devices, connecting to printers, and printing receipts or tickets. This package is ideal for developers looking to add thermal printing capabilities to their Flutter apps, such as POS systems, ticketing apps, and receipt printing solutions.
Features:
Scan for Bluetooth devices Connect to Bluetooth thermal printers Print receipts or tickets Easily integrate thermal printing into Flutter apps
Getting started
Getting Started
Prerequisites
Before using the bt-thermal
package, ensure you have the following prerequisites installed:
-
Flutter SDK: Make sure you have Flutter installed on your development environment. You can download it from the Flutter website.
-
Bluetooth Thermal Printer: You'll need a Bluetooth thermal printer compatible with your Flutter app. Ensure the printer is set up and ready to pair with your device.
Installation
To start using the bt-thermal
package, follow these steps:
-
Add the package to your
pubspec.yaml
file:dependencies: bt_thermal: ^1.0.0 # Replace with the latest version
-
Run the following command to install the package:
flutter pub get
Usage
After installing the package, you can import and use it in your Flutter project:
import 'package:bt_thermal/bt_thermal.dart';
// Example usage
void printReceipt() {
// Initialize Bluetooth thermal printer
BluetoothThermalPrinter printer = BluetoothThermalPrinter();
// Scan for available Bluetooth devices
printer.scanDevices().then((devices) {
// Connect to a specific Bluetooth printer
printer.connectToDevice(devices.first).then((connected) {
if (connected) {
// Print receipt content
printer.printText('Hello, world!\n\nThank you for shopping with us.');
printer.printNewLine();
printer.cutPaper();
printer.disconnect(); // Disconnect after printing
} else {
print('Failed to connect to the printer.');
}
});
});
}
For more detailed usage instructions and API documentation, refer to the package's [official documentation](https://pub.dev/packages/bt_thermal).
## Usage
```dart
import 'package:bt_thermal/bt_thermal.dart';
void main() {
// Initialize Bluetooth thermal printer
BluetoothThermalPrinter printer = BluetoothThermalPrinter();
// Example usage of printing a receipt
printReceipt(printer);
}
void printReceipt(BluetoothThermalPrinter printer) {
// Scan for available Bluetooth devices
printer.scanDevices().then((devices) {
// Connect to a specific Bluetooth printer
printer.connectToDevice(devices.first).then((connected) {
if (connected) {
// Print receipt content
printer.printText('Hello, world!\n\nThank you for shopping with us.');
printer.printNewLine();
printer.cutPaper();
printer.disconnect(); // Disconnect after printing
} else {
print('Failed to connect to the printer.');
}
});
});
}
Additional information
you have to call : BTthermalprinter(title:"name of your choice")
More Information
Documentation:
- Visit the official documentation for detailed guides, API references, and usage examples. GitHub Repository: Check out the GitHub repository for the latest code, issues, and contributions. Contributing
Support and Feedback We strive to provide timely and helpful responses to all inquiries. You can expect a response from the package maintainers within a reasonable time frame. For urgent matters or critical bugs, please mention it clearly in your issue or pull request.