xprinter_sdk 0.0.2 copy "xprinter_sdk: ^0.0.2" to clipboard
xprinter_sdk: ^0.0.2 copied to clipboard

An unofficial SDK for Xprinter brand printers, using the CPCL directive.

Xprinter_SDK #

XPrinter's Flutter version SDK

Getting Started #

For Android #

These need to be added to the project file android/build.gradle

allprojects {
    repositories {
        google()
        mavenCentral()
+       maven {
+           url "${project(':aar').projectDir}/build"  // for build.gradle
+           url = uri(project(":xprinter_sdk").projectDir.resolve("mvn")) // for build.gradle.kts
+       }
+       maven { url 'https://jitpack.io' }
    }
}

Use printer #

Start scanner #

XprinterSdk printer = XprinterSdk();
printer.startScanBluetooth();

Listen stream to display devices #

void listenDevices(List<BluetoothDevice> devices) {
  // your code
}
XprinterSdk.deviceScanner.listen(listenDevices);

or use StreamBuilder

StreamBuilder(
    stream: XprinterSdk.deviceScanner,
    initialData: <BluetoothDevice>[],
    builder: (BuildContext context, AsyncSnapshot<List<BluetoothDevice>> snapshot) {
      return YouWidget();
    }
)

Connect device #

bool result = await printer.connectDevice(mac);

Print #

printer.initializePrinter(height: 30, offset: 0, count: 1);

// Your print content
printer.drawText(0, 0, 'some text', font: XprinterFontTypes.FONT_5);
printer.drawBarcode(0, 18, XprinterBarCodeType.BC_128, 8, '1234567890');
// ... and more code

// Finally, start print
printer.print();

Disconnect device #

printer.disconnectDevice();
0
likes
150
points
26
downloads

Publisher

unverified uploader

Weekly Downloads

An unofficial SDK for Xprinter brand printers, using the CPCL directive.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

flutter, flutter_web_plugins, plugin_platform_interface, web

More

Packages that depend on xprinter_sdk

Packages that implement xprinter_sdk