initBluetoothPrinter static method

Future<bool> initBluetoothPrinter({
  1. KeckPaperSize size = KeckPaperSize.mm58,
  2. required String printerAddress,
})

Implementation

static Future<bool> initBluetoothPrinter({KeckPaperSize size = KeckPaperSize.mm58, required String printerAddress}) async {
  paperSize = size;
  _profile ??= await CapabilityProfile.load();

  if (_devicePrinter == null || !_devicePrinter!.isConnected) {
    await FlutterBluePlus.adapterState
        .firstWhere((s) => s == BluetoothAdapterState.on)
        .timeout(const Duration(seconds: 10));
    _devicePrinter = BluetoothDevice.fromId(printerAddress);
    await _devicePrinter!.connect(autoConnect: false, license: License.free);
  }

  return true;
}