transaction method

Future<T?> transaction(
  1. AsyncDataSinkSource port,
  2. Uint8List message,
  3. Duration duration
)

The transaction functions does 3 things.

  1. Flush the incoming queue
  2. Write the message
  3. Await the answer for at most "duration" time. returns List of bytes or null on timeout.

Implementation

Future<T?> transaction(
    AsyncDataSinkSource port, Uint8List message, Duration duration) async {
  await flush();
  port.write(message);
  return getMsg(duration);
}