Hey @dammy, could you create a gist with your full code? Happy to take a look and try to figure out a solution!
save user phone immediately, during create account
Votes
0
Replies
24
Participants
Unknown
Messages
25
based off of this, your createAcc() and addPhoneDetails() methods don't have a return type.
This isn't the best way to do this because:
in createAcc, you're returning the response, and if there's an error, you're returning a string. Those are two different types of Future:
submitDetails.then((response) {
if (response.statusCode == 201) {
debugPrint("successful");
}
return response;
}).catchError((error) {
return "An error occured";
});
How to resolve this? Try adding a return type of Future to the createAcc function. This will make sure that whatever gets, returned by the function, is of the type Future<something>. Then you can use await createAcc();. This should work because the function will wait for something to be returned; and that's when you use Future - when the returned value is computed/fetched after some time.
Do the same for the addPhoneDetails(), and see if it works. Let me know if there's any issues!
Rank 4: Virtual Machine
okay, but originally, submitDetails works, just addPhoneDetails() that is not adding phone number
Admin
Btw, response doesn't have a statusCode. I'm surprised your IDE isn't telling you that's a problem
Admin
Anyways, again, this comes down to futures and async programming. This is the same problem you're having: https://dart.dev/codelabs/async-await#example-incorrectly-using-an-asynchronous-function
account.create() is not finishing fully before you can account.updatePhone
Rank 4: Virtual Machine
I did this
Admin
Good. And?
Rank 4: Virtual Machine
account.create() is not finishing fully before you can account.updatePhone
I will check for this again
Rank 4: Virtual Machine
same issue
Admin
What's the full error you're seeing now?
Rank 4: Virtual Machine
the thing is, it is not adding phone number
Admin
Oh right....again you don't have a session. You need to create a session
Rank 4: Virtual Machine
ouch, no wonder
Rank 4: Virtual Machine
you mean login?
Rank 4: Virtual Machine
so, you mean during registration, phone can not be added?
Rank 4: Virtual Machine
here it is
Rank 4: Virtual Machine
because, I want to do email and phone verification in parallel
Admin
As part of the API, create account does not have a phone parameter.
Rank 4: Virtual Machine
that means I will request for phone after login?
Rank 4: Virtual Machine
or is it advisable to alter the sdk file?
not a good practice, and not recommended. You can register the user, then redirect them to add a phone number immediately after
Rank 4: Virtual Machine
ok then
Rank 4: Virtual Machine
Thanks man
no worries at all
Rank 4: Virtual Machine
I appreciate you all @safwan and @Steven
you all are the best, thanks for been of great help