cancel method

  1. @override
Future<void> cancel()
override

The run() function will run for 5 seconds or so, but if the user interrupts it, we can cancel the speech to text/wiki search and return to ApplicationState.ready state.

Implementation

@override
Future<void> cancel() async {
  // cancel listening (only if we currently are)
  await _stopListening();

  // let Frame know to stop sending taps
  await frame!.sendMessage(TxCode(msgCode: 0x10, value: 0));

  // clear the display
  await frame!.sendMessage(TxPlainText(msgCode: 0x0a, text: ' '));

  currentState = ApplicationState.ready;
  if (mounted) setState(() {});
}