flutter_bluetooth_serial icon indicating copy to clipboard operation
flutter_bluetooth_serial copied to clipboard

Return listen after sending

Open riteshghimire9090 opened this issue 3 years ago • 0 comments

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 ;
        }
});
  
}

riteshghimire9090 avatar Jun 07 '21 14:06 riteshghimire9090