### Start Scanning for Zebra Printers Source: https://github.com/anthonyr012/zebra_printer_utility/blob/master/README.md This method initiates the scanning process to discover available Zebra printers. The scan will continue until explicitly stopped, allowing the application to find nearby devices. ```Flutter zebraPrinter.startScanning(); ``` -------------------------------- ### Listen for Discovered Zebra Devices Source: https://github.com/anthonyr012/zebra_printer_utility/blob/master/README.md This `ListenableBuilder` example demonstrates how to use `zebraPrinter.controller` to reactively update the UI with discovered `ZebraDevice` instances. It displays a list of printers or a "not available" message if no devices are found. ```Flutter ListenableBuilder( listenable: zebraPrinter.controller, builder: (context, child) { final printers = zebraPrinter.controller.printers; if (printers.isEmpty) { return _getNotAvailablePage(); } return _getListDevices(printers); }, ) ``` -------------------------------- ### Initialize ZebraPrinter Instance in Flutter Source: https://github.com/anthonyr012/zebra_printer_utility/blob/master/README.md This Flutter `FutureBuilder` example demonstrates how to asynchronously obtain an instance of `ZebraPrinter` using `ZebraUtil.getPrinterInstance()`. It handles the loading state and passes the initialized `zebraPrinter` object to a `PrinterTemplate` widget for further use. ```Flutter FutureBuilder( future: ZebraUtil.getPrinterInstance(), //required async builder: (context, snapshot) { if (!snapshot.hasData) { return const Center( child: CircularProgressIndicator(), ); } final zebraPrinter = snapshot.data as ZebraPrinter; return PrinterTemplate(zebraPrinter); }, ), ``` -------------------------------- ### Stop Scanning for Zebra Printers Source: https://github.com/anthonyr012/zebra_printer_utility/blob/master/README.md This method halts the ongoing scanning process for Zebra printers. It should be called when printer discovery is no longer needed, for example, after a successful connection, to conserve resources. ```Flutter zebraPrinter.stopScanning(); ``` -------------------------------- ### Configure Android Packaging Options for ZebraUtil Source: https://github.com/anthonyr012/zebra_printer_utility/blob/master/README.md This snippet adds `packagingOptions` to the Android `build.gradle` file (module level) to exclude specific `META-INF` files. This prevents potential conflicts during build processes when integrating the Zebra utility plugin. ```sh android { packagingOptions { exclude 'META-INF/LICENSE.txt' exclude 'META-INF/NOTICE.txt' exclude 'META-INF/NOTICE' exclude 'META-INF/LICENSE' exclude 'META-INF/DEPENDENCIES' } } ``` -------------------------------- ### Connect to a Zebra Printer Source: https://github.com/anthonyr012/zebra_printer_utility/blob/master/README.md This method establishes a connection to a Zebra printer. It requires either the IP address for Wi-Fi printers or the MAC address for Bluetooth printers as a string argument. ```Flutter zebraPrinter.connectToPrinter("192.168.47.50"); ``` -------------------------------- ### Handle ZebraPrinter Discovery and Permission Errors Source: https://github.com/anthonyr012/zebra_printer_utility/blob/master/README.md This snippet shows how to assign callback functions to `onDiscoveryError` and `onPermissionDenied` properties of the `zebraPrinter` instance. These callbacks allow developers to handle and log specific errors that may occur during printer discovery or if necessary permissions are denied. ```Flutter zebraPrinter.onDiscoveryError = ( errorCode, errorText) { print("Error: $errorCode, $errorText"); }; zebraPrinter.onPermissionDenied = () { print("Permission denied"); } ``` -------------------------------- ### Add Android Bluetooth and Location Permissions for ZebraUtil Source: https://github.com/anthonyr012/zebra_printer_utility/blob/master/README.md This snippet shows the necessary `` tags to be included in the Android Manifest file. These permissions are required for the Zebra utility plugin to perform Bluetooth scanning and access fine/coarse location, which are essential for printer discovery. ```sh ``` -------------------------------- ### Print ZPL Commands to Zebra Printer Source: https://github.com/anthonyr012/zebra_printer_utility/blob/master/README.md This method sends ZPL (Zebra Programming Language) commands to the connected printer for printing. The ZPL string containing the print job is passed as an argument. ```Flutter zebraPrinter.print("Your ZPL"); ``` -------------------------------- ### Calibrate Zebra Printer Source: https://github.com/anthonyr012/zebra_printer_utility/blob/master/README.md This method initiates a calibration process for the connected Zebra printer. It is often called after setting the media type to ensure proper printing alignment and sensor readings. ```Flutter zebraPrinter.calibratePrinter(); ``` -------------------------------- ### Set Zebra Printer Media Type Source: https://github.com/anthonyr012/zebra_printer_utility/blob/master/README.md This method allows setting the media type for the connected Zebra printer. Valid options are `Lable`, `Journal`, and `BlackMark`, chosen from the `EnumMediaType` enumeration. ```Flutter zebraPrinter.setMediaType(EnumMediaType.BlackMark); ``` -------------------------------- ### Rotate ZPL Output on Zebra Printer Source: https://github.com/anthonyr012/zebra_printer_utility/blob/master/README.md This method toggles the rotation of ZPL output without requiring modifications to the ZPL code itself. Calling it again will revert to normal printing orientation. ```Flutter zebraPrinter.rotate(); ``` -------------------------------- ### Set Zebra Printer Darkness Level Source: https://github.com/anthonyr012/zebra_printer_utility/blob/master/README.md This method adjusts the darkness level of the printer output. The valid darkness values range from -99 to 200, including specific increments like -75, -50, -25, 0, 25, 50, 75, 100, 125, 150, 175, and 200. ```Flutter zebraPrinter.setDarkness(25); ``` -------------------------------- ### Disconnect from Zebra Printer Source: https://github.com/anthonyr012/zebra_printer_utility/blob/master/README.md This method terminates the connection to the Zebra printer. It is recommended to disconnect when the printer is no longer needed to conserve battery life and resources. ```Flutter zebraPrinter.disconnect(); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.