flutter embedded pos printer (Like: Android Q2 device)

2.3k views Asked by At

Already I have built a flutter project. Now I need to print from a pos embedded device. I am googling, but I don't get any solution.

Please help me if there is any solution.

Actually I need for Android Q2 device

Android Q2 device 

3

There are 3 answers

0
Mauricio Oyanedel On

Try this library "flutter_bluetooth_serial" and connect to the printer via direct mac address like this:

BluetoothConnection connection = await BluetoothConnection.toAddress("mac");

6
Nishuthan S On

EDIT:

In your case, you can download the SDK provided by the company and write native code to print the receipt.

example:

in flutter

static const platform = const MethodChannel('com.example.myapplication');

Future<void> _print() async {
    try {
        final bool result = await platform.invokeMethod('print',{"data":Printdata});
        if (result) {
            // success
        } else {
            // failed
        }
    } on PlatformException catch (e) {
        //failed to print
    }
}

Then in the Main.java / Main.kt implement the method from the SDK documentation

example:

public void onMethodCall(MethodCall call, MethodChannel.Result result) {
    if (call.method.equals("print")) {
        data = call.argument("data");
        // Code from SDK documentation
    } else {
        result.notImplemented();
    }
}

ref: Example Nativcode in flutter

Add third party SDK to android

1
mohannad youssef On

I have the same device and i already built flutter application , and ran into the same probleme . I contacted the company and they provided me with android sdk so i added a channel and called the print from the flutter code.