5

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 

  • did you resolved this problem? – Michael Mendoza Oct 09 '22 at 17:56
  • @MichaelMendoza, no I couldn't Because it was earlier 2018 model sdk. which cannot be added directly. So I write custom function to add this sdk. But it takes time to print – Syed Tanvir Hossan Oct 11 '22 at 05:28
  • Can you get solution for this issue? I can't also printing with flutter app that embedded on device. That mean printing not work forever and sometime get output. But can print from emulator. – La Pyae Dec 02 '22 at 03:25
  • 1
    @LaPyae Q2 device version is not compatible which I was used. I update the device and use company provided android sdk nd called the print from the flutter code. – Syed Tanvir Hossan Dec 06 '22 at 11:08
  • Yes ... I also contact company and they fix with local ip REST API. – La Pyae Dec 06 '22 at 16:19

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,324
  • 26
  • 22
  • 31
Nishuthan S
  • 1,538
  • 3
  • 12
  • 30
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");