Open Application Platform Docs

Migrating from superprinter_flutter

Moving a Flutter app from superprinter_flutter to sprint_flutter.

Two ways

  1. Change one import. The compat layer of sprint_flutter has the classes and calls of superprinter_flutter with the same names, fields, defaults and JSON. Start with this.
  2. Move to the sprint_flutter API. Use SPrint, Discovery, PrinterRegistry and PrintNode when a screen is changed anyway. The compat printers convert with TargetPrinter.toSprint().
# pubspec.yaml
dependencies:
  sprint_flutter: ^0.1.6      # was: superprinter_flutter

// Dart
import 'package:sprint_flutter/superprinter_compat.dart'
    show FailReason, JobStatus, LabelJob, LocalPrinting, PrintResult, PrinterRegistry;

The saved printers stay where they are: the compat registry reads and writes the same stored settings as superprinter_flutter.

Setup

Call by call

superprinter_flutter Compat layer sprint_flutter API
LocalPrinting() LocalPrinting() SPrint, Discovery, PrinterRegistry.open()
printing.printLabel(label, printerName:, html:, copies:) printing.printLabel(…) registry.print(PrintJob(type: JobTypes.label, …))
printing.printHtml(html, …) printing.printHtml(…) PrintJob(type: JobTypes.html, html:, baseUrl:)
printing.printPdf(bytes, …) printing.printPdf(…) PrintJob(type: JobTypes.pdf, data:)
printing.printRaw(bytes, …) printing.printRaw(…) PrintJob(type: JobTypes.raw, data:)
printing.selfTest(printer) printing.selfTest(printer) PrintJob(type: JobTypes.test), SPrint.testPagePdf()
printing.identify(printer) printing.identify(printer) SPrint.identifyPrinter(printer)
printing.checkLanguage(printer) printing.checkLanguage(printer) SPrint.probeLanguage(printer)
printing.detectLanguage(printer) printing.detectLanguage(printer) SPrint.detectLanguage(printer)
printing.scanNetwork(subnet) printing.scanNetwork(subnet) Discovery.scanNetwork(prefix:)
printing.bondedPrinters() printing.bondedPrinters() Discovery.bluetoothPrinters()
printing.scanBle(duration:) printing.scanBle(duration:) Discovery.blePrinters(scanMs:)
— printing.nearbyBluetooth(duration:) Discovery.nearbyBluetoothPrinters(scanMs:)
printing.usbPrinters() printing.usbPrinters() Discovery.usbPrinters()
printing.setModelTable(json) printing.setModelTable(json) SPrint.loadModelTable(json)
PrinterRegistry() PrinterRegistry() PrinterRegistry.open(path)
PrintNodeService + PrinterPort — PrintNode.create(registry, state:)

What changes