Created
August 7, 2020 17:52
-
-
Save rodrigolmacedo/19590a5b6e26251775268e45ca24f82f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<ReactionDisposer> _disposers; | |
@override | |
void initState() { | |
super.initState(); | |
_disposers ??= [ | |
reaction( | |
// Tell the reaction which observable to observe | |
(_) => _controller.msg, | |
// Run some logic with the content of the observed field | |
(String message) { | |
if (message.isNotEmpty) { | |
showDialog( | |
context: context, | |
builder: (BuildContext context) { | |
return Dialog( | |
shape: RoundedRectangleBorder( | |
borderRadius: | |
BorderRadius.circular(20.0)), //this right here | |
child: Container( | |
height: 100, | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.spaceEvenly, | |
crossAxisAlignment: CrossAxisAlignment.start, | |
children: [ | |
Center(child: Text(message)), | |
Center( | |
child: RaisedButton( | |
onPressed: () { | |
Navigator.pop(context); | |
}, | |
child: Text( | |
"Ok", | |
style: TextStyle(color: Colors.white), | |
), | |
color: Color.fromRGBO(109, 207, 246, 0.9), | |
), | |
), | |
], | |
), | |
), | |
); | |
}); | |
} | |
}, | |
), | |
]; | |
} | |
////// fim widget | |
//controller | |
@observable | |
String msg; | |
@action | |
alterarEndereco(String valor) async { | |
loading = true; | |
msg = null; | |
try { | |
await _repository.alterarEndereco(valor); | |
msg = "Alterado com sucesso."; | |
} on DioError catch (e) { | |
print(e?.response?.data); | |
//pegar do response.data | |
msg = "Ocorreu um erro"; | |
} finally { | |
loading = false; | |
Modular.to.pop(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment