pop删除顶级窗口小部件。不确定在此之后加上逻辑是一个好主意。最好重新安排代码,例如
// only gets SMS, no functionality Future<String> getSmsCode(BuildContext context) { return showDialog<String>( context: context, barrierDismissible: false, builder: (BuildContext context) { return alertDialog( title: Text('SMS 코드를 입력해주세요'), content: TextField( onChanged: (value) { this.smsCode = value; }, ), contentPadding: EdgeInsets.all(10), actions: <Widget>[ FlatButton( child: Text('Done'), onPressed: () { Navigator.of(context).pop(this.smsCode); }, ) ], ); }, ); } SIGNIn() async { String smsCode = await getSmsCode(context); if (smsCode != null && !smsCode.isNotEmpty) { print('User cancelled SMS dialog'); return; } final AuthCredential credential = PhoneAuthProvider.getCredential( verificationId: verificationId, smsCode: smsCode, ); print('진행중'); FirebaseAuth _auth = FirebaseAuth.instance; final FirebaseUser user = (await _auth.signInWithCredential(credential)).user; final FirebaseUser currentUser = await _auth.currentUser(); assert(user.uid == currentUser.uid); setState(() { if (user != null) { print('success!'); } else { print('sign in failed'); } }); }
现在仅调用
SIGNIn,它将首先获取SMS代码,然后使用该SMS代码登录。希望能帮助到你。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)