If on Mac:
another_brother is a Flutter plugin for Brother Label printers. This means there is native code running on each of the platforms (Android/iOS) that facilitate the printing.
It is port of the Android SDK (v3) and as a result the Android documentation and samples from the official Brother developer site can be followed while coding your Flutter app.
All connection channels are supported:
Supports all label types and printer types supported by the Brother SDK(s) at the time of this writing.
Install another_brother
flutter pub add another_brother
In order to print we'll first need to define what printer we are going to print on, what label (or paper) the printer has and what channel of communication we'll use to send the print request to the printer.
The another_brother plugin allows for a large level of detail when specifing your print. In this section however we'll just present the most basic setup to get you printing.
The snippet below shows how to print to a 1110NWB printer with a W103 label (103mm wide) talking over Bluetooth Classic.
var printer = new Printer();
var printInfo = PrinterInfo();
printInfo.printerModel = Model.QL_1110NWB;
printInfo.printMode = PrintMode.FIT_TO_PAGE;
printInfo.isAutoCut = true;
printInfo.port = Port.BLUETOOTH;
// Set the label type.
printInfo.labelNameIndex = QL1100.ordinalFromID(QL1100.W103.getId());
// Set the printer info so we can use the SDK to get the printers.
await printer.setPrinterInfo(printInfo);
With the printer configured we then need to find a specific printer to connect to by looking for a list of printers bonded to the device. In this example we are connecting over Bluetooth but similar methods exist WiFi.
List<BluetoothPrinter> printers = await printer.getBluetoothPrinters([Model.QL_1110NWB.getName()]);
Since at this point we are not interested in any specific printer we'll just grab the first one and print to it.
printInfo.macAddress = printers.single.macAddress;
printer.setPrinterInfo(printInfo);
And last but not least we'll print an image from our assets folder.
PrinterStatus status = await printer.printImage(await loadImage('assets/brother_hack.png'));