Created
May 4, 2021 20:59
-
-
Save guilhermecarvalhocarneiro/a92b0c96af4bb32f903f27bb32f1b062 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<void> signUpWithOTP() async { | |
try { | |
setState(() { | |
_isProcessing = true; | |
}); | |
var phoneNumber = "+55 ${_phoneOTPController.text.trim()}"; | |
var verifyPhoneNumber = firebaseAuth.verifyPhoneNumber( | |
phoneNumber: phoneNumber, | |
verificationCompleted: (phoneAuthCredential) async { | |
final _signInWithCredential = await firebaseAuth.signInWithCredential(phoneAuthCredential); | |
if (_signInWithCredential != null) { | |
DebugPrint.print("Usuário: ${_signInWithCredential.toString()} registrado"); | |
} | |
}, | |
verificationFailed: (FirebaseAuthException error) { | |
DebugPrint.error("Erro ao enviar o código: $error"); | |
setState(() { | |
_isProcessing = false; | |
}); | |
}, | |
codeSent: (verificationId, [forceResendingToken]) { | |
DebugPrint.print("Código: $verificationId"); | |
setState(() { | |
_isProcessing = false; | |
}); | |
}, | |
codeAutoRetrievalTimeout: (String verificationId) { | |
DebugPrint.print("Código: $verificationId"); | |
setState(() { | |
_isProcessing = false; | |
}); | |
}, | |
timeout: Duration(seconds: 60), | |
); | |
await verifyPhoneNumber; | |
} catch (e) { | |
DebugPrint.error("DebugError: Erro $e ao executar o signUpWithOTP do _SignupPageState"); | |
} finally { | |
setState(() { | |
_isProcessing = false; | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment