diff --git a/lib/pages/create-account/create-account.page.dart b/lib/pages/create-account/create-account.page.dart index 47fd623..aadc28c 100644 --- a/lib/pages/create-account/create-account.page.dart +++ b/lib/pages/create-account/create-account.page.dart @@ -26,16 +26,21 @@ class _CreateAccountPageState extends State { ); var user = auth.user; - String fileName = this.email + '.jpg'; - StorageReference firebaseStorageRef = - FirebaseStorage.instance.ref().child('images/' + fileName); - StorageUploadTask uploadTask = firebaseStorageRef.putFile(image); - StorageTaskSnapshot taskSnapshot = await uploadTask.onComplete; - String downloadUrl = await taskSnapshot.ref.getDownloadURL(); + String downloadUrl = ""; + if (image != null) { + String fileName = this.email + '.jpg'; + StorageReference firebaseStorageRef = FirebaseStorage.instance.ref().child('images/' + fileName); + StorageUploadTask uploadTask = firebaseStorageRef.putFile(image); + StorageTaskSnapshot taskSnapshot = await uploadTask.onComplete; + downloadUrl = await taskSnapshot.ref.getDownloadURL(); + } + UserUpdateInfo info = new UserUpdateInfo(); info.displayName = this.nome; - info.photoUrl = downloadUrl; + if (downloadUrl != "") { + info.photoUrl = downloadUrl; + } await user.updateProfile(info); await user.reload(); @@ -60,6 +65,30 @@ class _CreateAccountPageState extends State { return user; } + void _showDialog() { + // flutter defined function + showDialog( + context: context, + builder: (BuildContext context) { + // return object of type Dialog + return AlertDialog( + title: new Text("Sucesso!"), + content: new Text("Cadastro realizado"), + actions: [ + // usually buttons at the bottom of the dialog + new FlatButton( + child: new Text("Fechar"), + onPressed: () { + Navigator.of(context).pop(); //fecha o dialog + Navigator.pop(context); // volta para a pagina anterior + }, + ), + ], + ); + }, + ); + } + @override Widget build(BuildContext context) { return Scaffold( @@ -182,10 +211,11 @@ class _CreateAccountPageState extends State { width: 1), onPressed: () async { try { - var user = await _handleCreateAccount(); - print(user); + var user = await _handleCreateAccount(); + print(user); if (user != null) { - Navigator.pop(context); + this._showDialog("Sucesso!", "Cadastro Realizado", "Fechar"); + // Navigator.pop(context); } //var snackBar = // SnackBar(content: Text('Usuário ' + user.displayName + ' logado!'));