print method

Future<void> print({
  1. required String address,
  2. ProgressCallback? onProgress,
  3. int addFeeds = 0,
  4. bool useImageRaster = false,
  5. bool keepConnected = false,
})

Implementation

Future<void> print({
  required String address,
  ProgressCallback? onProgress,
  int addFeeds = 0,
  bool useImageRaster = false,
  bool keepConnected = false,
}) async {
  int quality = 4;
  final RenderRepaintBoundary boundary =
      _localKey.currentContext!.findRenderObject() as RenderRepaintBoundary;
  final image = await boundary.toImage(pixelRatio: quality.toDouble());
  final byteData = await image.toByteData(format: ImageByteFormat.rawRgba);
  final bytes = byteData!.buffer.asUint8List();

  await FlutterBluetoothPrinter.printImage(
    address: address,
    imageBytes: bytes,
    imageWidth: image.width,
    imageHeight: image.height,
    paperSize: _paperSize,
    onProgress: onProgress,
    addFeeds: addFeeds,
    useImageRaster: useImageRaster,
    keepConnected: keepConnected,
  );
}