flutter_bluetooth_serial
flutter_bluetooth_serial copied to clipboard
Return listen after sending
Is there any way to return the listen data after sending the data. Here is my code please suggest me how can we achieve it.
//Sending the data
void sendMessage(String text) async {
this.connection =
Provider.of<ObdProvider>(navigatorKey.currentContext, listen: false)
.connection;
print(this.connection.toString());
text = text.trim();
if (text.length > 0) {
try {
this.connection.output.add(utf8.encode(text + "\r\n"));
await this.connection.output.allSent;
} catch (e) {
print(e);
}
}
this.connection.input.listen((Uint8List data) {
String dataStr = ascii.decode(data);
message += dataStr;
if (dataStr.contains('\r')) {
return this.message ;
}
});
}