'How to bond/pair a bluetooth device programmatically in Flutter?

Is it possible to bond/pair a bluetooth device programmatically in Flutter? I don't want to show the message to enter the pin. Instead I want to hardcode it and get paired in a single button tap. I am using flutter_bluetooth_serial package to search and connect bluetooth devices.

It is showing alert box to enter the pin if I use the following code.

 await FlutterBluetoothSerial
 .instance
 .bondDeviceAtAddress(deviceAddress); 

When I use like below, It is not connecting and getting timeout error.

 await FlutterBluetoothSerial
 .instance
 .bondDeviceAtAddress(deviceAddress, pin: "1234") 

If it is not possible with this package, please suggest a solution in native (Kotlin), So that I can use platform channel.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source