Created
October 20, 2019 07:14
-
-
Save rpsnaik/142c73d758876198a7fb239e31cbcb32 to your computer and use it in GitHub Desktop.
This file contains 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
Future<bool> signUp(BuildContext context ,String name ,String email, String password)async{ | |
isCreatingAccount = true; | |
notifyListeners(); | |
try{ | |
FirebaseUser user = await FirebaseAuth.instance.createUserWithEmailAndPassword(email: email, password: password); | |
print("Signed up as : "+user.uid); | |
await Firestore.instance.collection("users").document(user.uid).setData({ | |
"name": name, | |
"nameIndex": name[0], | |
"premiumMember": false, | |
"email": email, | |
"uid": user.uid | |
}); | |
isCreatingAccount = false; | |
notifyListeners(); | |
Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context)=>MultiProvider( | |
providers: [ | |
ChangeNotifierProvider(builder: (_)=>SessionManagement(),) | |
], | |
child: SpotifyHome(), | |
)), (Route<dynamic> route)=>false); | |
return true; | |
}catch(e){ | |
final ShowCustomAlertDialog showCustomAlertDialog = ShowCustomAlertDialog(); | |
print(e.message); | |
isCreatingAccount = false; | |
notifyListeners(); | |
showCustomAlertDialog.showCustomDialog(context, e.message); | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment