onSpeechResult method
void
onSpeechResult(
- SpeechRecognitionResult result
Implementation
void onSpeechResult(SpeechRecognitionResult result) {
setState(() {
_lastWords = result.recognizedWords;
_controller.text = _lastWords;
_controller.selection = TextSelection.fromPosition(
TextPosition(offset: _controller.text.length),
);
});
if (result.finalResult) {
_stopListening();
// Send message and clear the controller
if (_controller.text.isNotEmpty) {
sendMessage(_controller.text);
_controller.clear();
_lastWords = '';
}
}
}