Skip to content

Instantly share code, notes, and snippets.

@rpsnaik
Created October 20, 2019 07:14
Show Gist options
  • Save rpsnaik/142c73d758876198a7fb239e31cbcb32 to your computer and use it in GitHub Desktop.
Save rpsnaik/142c73d758876198a7fb239e31cbcb32 to your computer and use it in GitHub Desktop.
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