0
I have a Custonalertdialog that saves information in the bank, for this, by clicking the SEND button I use a await. The information is saved in the database successfully, but the application hangs and does not execute the command to close Alert "Navigator.pop".
class ConfirmarPresencaWidget extends StatelessWidget {
final ValueChanged<bool> parentAction;
ConfirmarPresencaController controller = Modular.get();
ConfirmarPresencaWidget({Key key, this.parentAction}) : super(key: key);
//var mask = MaskedTextController(mask: '(00) 0 0000.0000');
@override
Widget build(BuildContext context) {
return AlertDialog(
title: new Text("Confirme sua presença"),
content: Container(
child: Container(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
//*NOME E SOBRENOME
TextField(
onChanged: (value) {
controller.nome = value;
controller.checkIsValid();
},
maxLength: 30,
decoration: InputDecoration(
labelText: 'Nome e sobrenome',
counterStyle: TextStyle(fontSize: 0)),
),
//* TELEFONE
TextField(
//TODO verificar possível troca da máscara: parece não ter suporte WEB
//controller: mask,
onChanged: (value) {
controller.telefone = value;
controller.checkIsValid();
},
keyboardType: TextInputType.number,
inputFormatters: <TextInputFormatter>[
WhitelistingTextInputFormatter.digitsOnly
],
decoration: InputDecoration(
labelText: 'Telefone',
counterStyle: TextStyle(fontSize: 0)),
),
Padding(
padding: EdgeInsets.only(bottom: 30),
),
//* QUANTIDADE DE ADULTOS E CRIANCAS
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Column(
children: <Widget>[
Text('adultos'),
QuantidadeInputWidget(
parentAction: controller.setAdultos,
value: 1,
),
],
),
Column(
children: <Widget>[
Text('crianças'),
QuantidadeInputWidget(
parentAction: controller.setCriancas,
value: 0,
),
],
),
],
),
],
),
),
),
actions: <Widget>[
//* define os botões na base do dialogo
RaisedButton(
color: Colors.blue,
child: new Text("Cancelar"),
onPressed: () async {
Navigator.of(context).pop();
},
),
Observer(builder: (_) {
return RaisedButton(
color: Colors.blue,
child: new Text("Enviar"),
onPressed: controller.isValid
? () async {
var result = await controller.enviarConfirmacao();
Navigator.pop(context);
}
: null,
);
}),
],
);
}
}
It’s the controller’s code.()?
– Julio Henrique Bitencourt