cancel method

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

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

Implementation

@override
Future<void> cancel() async {
  await _stopListening();
  currentState = ApplicationState.ready;
  if (mounted) setState(() {});
}