Migrating from superprinter_flutter
Moving a Flutter app from superprinter_flutter to sprint_flutter.
Two ways
- 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.
- 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
- iOS: keep the Bluetooth usage description and add the local network usage description for network printers. The plugin uses Swift Package Manager and needs iOS 15 or later.
- Android: the library declares the permissions. Ask for the runtime permissions with Discovery.requestBluetoothPermissions() or with your own permission flow.
- Remove superprinter_flutter and the packages it brought in when nothing else uses them.
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
- One printing engine on every platform, with the same bytes as the SuperPrinter agent, instead of a separate engine on Android and on iOS.
- Bluetooth discovery lists every device found, likely printers first. Printers that superprinter_flutter did not find are listed.
- On iOS there are no bonded classic Bluetooth printers, and printing to a classic Bluetooth printer fails with a clear error.
- XPP printers over Bluetooth LE are drawn 832 dots wide when no width is set, so the Phomemo M832 also prints on Android.
- A printer that asks to pair gets time for the user's answer on the first job.
- On iOS a network document printer receives the PDF over IPP without a print dialog.
- The compat printers keep the defaults of superprinter_flutter (384 dots, 203 dpi, ESC/POS), so saved printers print the same.
- The compat layer also prints on macOS, Windows and Linux.