Skip to content

Instantly share code, notes, and snippets.

@flakerimi
Last active November 16, 2021 15:41
Show Gist options
  • Save flakerimi/ebb798e912902d0d85deb55e154e22d3 to your computer and use it in GitHub Desktop.
Save flakerimi/ebb798e912902d0d85deb55e154e22d3 to your computer and use it in GitHub Desktop.
Login
class Login extends StatelessWidget {
final _phoneController = TextEditingController();
void verifyPhone(_phoneController) async {
FirebaseAuth _auth = FirebaseAuth.instance;
_auth.verifyPhoneNumber(
phoneNumber: _phoneController.text,
timeout: const Duration(seconds: 60),
verificationCompleted: (PhoneAuthCredential credential) async {
// ANDROID ONLY!
// Sign the user in (or link) with the auto-generated credential
await auth.signInWithCredential(credential);
},
verificationFailed: (FirebaseAuthException exception) {},
codeSent: (String verificationId, int? resendToken) async {
// Update the UI - wait for the user to enter the SMS code
verifyCode(verificationId, smsController);
// Create a PhoneAuthCredential with the code
},
codeAutoRetrievalTimeout: (String verificationId) {});
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment