kakzaki / blue_thermal_printer

Working with thermal printer via bluetooth (Flutter)
MIT License
164 stars 205 forks source link

can not connect to thermal printer #188

Closed toulaoBD closed 10 months ago

toulaoBD commented 1 year ago

void _connect() { if (_device == null) { show('No device selected.'); } else { bluetooth.isConnected.then((isConnected) { if (isConnected==true) { bluetooth.connect(_device!).catchError((error) { setState(() => _connected = false); }); setState(() => _connected = true); } }); } }

muhd-ameen commented 1 year ago

@kakzaki, getting the same issue while connecting

void _connect() { if (_device != null) { bluetooth.isConnected.then((isConnected) { if (isConnected == true) { show('Device connected!'); bluetooth.connect(_device!).catchError((error) { setState(() => _connected = false); }); setState(() => _connected = true); } else { show('Device not connected!'); } }); } else { show('No device selected.'); } }

ALLY-MAFTAH commented 1 year ago

The example code has logical error in its condition. Replace if (isConnected==true) with if (isConnected != true)

github-actions[bot] commented 10 months ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.