aboutsummaryrefslogtreecommitdiff
path: root/lib/screens/register_screen.dart
diff options
context:
space:
mode:
Diffstat (limited to 'lib/screens/register_screen.dart')
-rw-r--r--lib/screens/register_screen.dart49
1 files changed, 35 insertions, 14 deletions
diff --git a/lib/screens/register_screen.dart b/lib/screens/register_screen.dart
index 9a11923..0ba0cf9 100644
--- a/lib/screens/register_screen.dart
+++ b/lib/screens/register_screen.dart
@@ -158,21 +158,42 @@ class _RegisterScreenState extends State<RegisterScreen> {
void onRegisterClicked(BuildContext context) {
setState(() {
- isLoading = false;
- if (validateForm()) {
- Auth()
- .createUserWithEmailAndPassword(
- email: _emailController.text,
- password: _passwordController.text,
- displayName: _nameController.text,
- avatar: File(_avatar!.path),
- )
- .then((success) {
- if (success) {
- Navigator.of(context).pushReplacementNamed('/onboard');
+ isLoading = true;
+ });
+
+ if (validateForm()) {
+ Auth()
+ .createUserWithEmailAndPassword(
+ email: _emailController.text,
+ password: _passwordController.text,
+ displayName: _nameController.text,
+ avatar: File(_avatar!.path),
+ )
+ .then((result) {
+ setState(() {
+ isLoading = false;
+ });
+ result.fold((user) {
+ Navigator.of(context).pushReplacementNamed('/login');
+ }, (error) {
+ String message;
+ switch (error.code) {
+ case 'email-already-in-use':
+ message = 'El correo electrónico ya se encuentra en uso';
+ case 'invalid-email':
+ message = 'El correo electrónico es inválido';
+ case 'operation-not-allowed':
+ message = 'La operación no está permitida';
+ case 'weak-password':
+ message = 'La contraseña es muy débil';
+ default:
+ message = 'Ocurrió un error desconocido';
}
+ ScaffoldMessenger.of(context).showSnackBar(
+ SnackBar(content: Text(message)),
+ );
});
- }
- });
+ });
+ }
}
}