Developers need to work with Bluetooth communication in many cases such as connecting to a printer or a headphone. Following are the best Flutter Bluetooth packages.
To use Bluetooth in either Android or iOS, you need to add permissions to AndroidManifest.xml
or Info.plist
.
//Android <uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> //iOS <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>
Table of Contents
flutter_blue
FlutterBlue helps connecting and communicating with Bluetooth Low Energy devices. It supports Android and iOS. This package is under active development, so there might be break changes in upcoming version.
bluetooth bluetooth = bluetooth.instance; //scan and find Bluetooth devices bluetooth.startScan(timeout: Duration(seconds: 6)); var subscription = bluetooth.scanResults.listen((results) { // do something with scan results for (ScanResult r in results) { print('${r.device.name} found! rssi: ${r.rssi}'); } }); bluetooth.stopScan();
flutter_ble_lib
flutter_ble_lib is a Flutter library which works with Bluetooth Low Energy. It supports BLEmulator, the BLE simulator, which make using it to devleop Bluetooth app easier.
BleManager bleManager = BleManager(); await bleManager.createClient(); BluetoothState currentState = await bleManager.bluetoothState(); bleManager.observeBluetoothState().listen((btState) { print(btState); }); bleManager.destroyClient();
blue_thermal_printer
This plugin help connects your Android device to a thermal printer.
BlueThermalPrinter bluetooth = BlueThermalPrinter.instance; List<BluetoothDevice> devices = []; try { devices = await bluetooth.getBondedDevices(); } on PlatformException { print('Error'); } bluetooth.onStateChanged().listen((state) { switch (state) { case BlueThermalPrinter.CONNECTED: break; case BlueThermalPrinter.DISCONNECTED: break; default: print(state); break; } });
bluetooth_print
This plugin also allows a device to connect to a thermal printer. Furthermore, it supports both Android and iOS.

bluetooth bluetooth = bluetooth.instance; // scan and get devices bluetooth.startScan(timeout: Duration(seconds: 4)); // get devices StreamBuilder<List<BluetoothDevice>>( stream: bluetooth.scanResults, initialData: [], builder: (c, snapshot) => Column( children: snapshot.data.map((d) => ListTile( title: Text(d.name??''), subtitle: Text(d.address), onTap: () async { setState(() { _device = d; }); }, trailing: _device!=null && _device.address == d.address?Icon( Icons.check, color: Colors.green, ):null, )).toList(), ), ), //connect and disconnect a device await bluetooth.connect(_device); await bluetooth.disconnect(); //print Map<String, dynamic> config = Map(); config['width'] = 50; config['height'] = 60; config['gap'] = 3; List<LineText> data = List(); list.add(LineText(type: LineText.TYPE_TEXT, content: 'A Title', weight: 1, align: LineText.ALIGN_CENTER,linefeed: 1)); list.add(LineText(type: LineText.TYPE_TEXT, content: 'this is conent left', weight: 0, align: LineText.ALIGN_LEFT,linefeed: 1)); list.add(LineText(type: LineText.TYPE_TEXT, content: 'this is conent right', align: LineText.ALIGN_RIGHT,linefeed: 1)); list.add(LineText(linefeed: 1)); list.add(LineText(type: LineText.TYPE_BARCODE, content: 'A12312112', size:10, align: LineText.ALIGN_CENTER, linefeed: 1)); list.add(LineText(linefeed: 1)); list.add(LineText(type: LineText.TYPE_QRCODE, content: 'qrcode i', size:10, align: LineText.ALIGN_CENTER, linefeed: 1)); list.add(LineText(linefeed: 1)); await bluetooth.printReceipt(config, data);
quick_blue
This is a cross-platform BluetoothLE plugin for Flutter, which supports Android, iOS, macOS, and Windows. This is the most versatile bluetooth plugin yet.
QuickBlue.setConnectionHandler(_handleConnectionChange); void _handleConnectionChange(String deviceId, BlueConnectionState state) { print('_handleConnectionChange $deviceId, $state'); } QuickBlue.connect(deviceId); QuickBlue.disconnect(deviceId);