Tengo una aplicacion en Flutter y Dart usando como IDE VSCode, esta aplicacion tiene una funcionalidad de mensajeria y los mensajes se envian bien pero cuando se recibe un mensaje, aparece "La aplicacion se ha detenido". Al presionar el boton de enviar lleva al metodo _handleSubmitted, dicho metodo se presenta en el codigo, se cree que la aplicacion se detiene porque catch no captura la excepcion, pero que podria ser?
Future<void> _handleSubmitted(String text) async {
try {
setState(() {
_isLoading = true;
});
await ControlFirebase.instanace.sendMessageToChat(widget.chatID,
widget.myID, widget.seleccionUsuarioID, text, messageType);
await ControlFirebase.instanace.updateChatRequestField(
widget.seleccionUsuarioID,
messageType == 'text' ? text : 'text',
widget.chatID,
widget.myID,
widget.seleccionUsuarioID);
await ControlFirebase.instanace.updateChatRequestField(
widget.myID,
messageType == 'text' ? text : 'text',
widget.chatID,
widget.myID,
widget.seleccionUsuarioID);
_getUnreadMSGCountThenSendMessage();
} catch (e) {
_showDialog('Existe un error en la Información del usuario');
_resetTextFieldAndLoading();
}
}
_resetTextFieldAndLoading() {
FocusScope.of(context).requestFocus(FocusNode());
_msgTextController.text = '';
setState(() {
_isLoading = false;
});
}
_showDialog(String msg) {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
content: Text(msg),
);
});
}