printer_plus

A Flutter plugin for print text, qrcode, barcode label to printer via bluetooth.

Using

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile and web development, and a full API reference.

Installation

First, add printer_plus as a dependency in your pubspec.yaml file.

In your flutter project add the dependency:

dependencies:
  ...
  printer_plus:

For help getting started with Flutter, view the online documentation.

Platform Support

Android iOS MacOS Web Linux Windows
✔️ ️X ️X ️X ️X ️X

Setup

Change the minSdkVersion for Android

Flutter_blue is compatible only from version 19 of Android SDK so you should change this in android/app/build.gradle:

Android {
  defaultConfig {
     minSdkVersion: 19

Add permissions for Bluetooth

We need to add the permission to use Bluetooth and access location:

Android

In the android/app/src/main/AndroidManifest.xml let’s add:

	 <uses-permission android:name="android.permission.BLUETOOTH" />  
	 <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />  
	 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
     <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
     <uses-permission android:name="android.permission.BLUETOOTH_SCAN" />

IOS

In the ios/Runner/Info.plist let’s add:

	<dict>  
	    <key>NSBluetoothAlwaysUsageDescription</key>  
	    <string>Need BLE permission</string>  
	    <key>NSBluetoothPeripheralUsageDescription</key>  
	    <string>Need BLE permission</string>  
	    <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>  
	    <string>Need Location permission</string>  
	    <key>NSLocationAlwaysUsageDescription</key>  
	    <string>Need Location permission</string>  
	    <key>NSLocationWhenInUseUsageDescription</key>  
	    <string>Need Location permission</string>

For location permissions on iOS see more at: https://developer.apple.com/documentation/corelocation/requesting_authorization_for_location_services

Example

Please follow this example here.

TSCBTPrinter.printText(macAddress: "MAC Address", content: "datadirr");
TSCBTPrinter.printQR(macAddress: "MAC Address", content: "datadirr");
TSCBTPrinter.printBarcode(macAddress: "MAC Address", content: "datadirr");