4

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 Answers3

0

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

Tyler2P
  • 2,182
  • 12
  • 17
  • 28
Nishuthan S
  • 1,262
  • 1
  • 11
  • 26
0

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.

0

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

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