Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 侧面表单中的flatterfirebase身份验证问题_Flutter - Fatal编程技术网

Flutter 侧面表单中的flatterfirebase身份验证问题

Flutter 侧面表单中的flatterfirebase身份验证问题,flutter,Flutter,您好,我正在尝试在firebase上构建一个带有Flitter集成的身份验证系统。我已经正确地集成了所有firebase类exc。在我的注册页面中,我声明了firebase的授权人使用的字符串email class _RegisterState extends State<Register> { String = email; 错误: I/flutter ( 3037): Error: 'package:firebase_auth/src/firebase

您好,我正在尝试在firebase上构建一个带有Flitter集成的身份验证系统。我已经正确地集成了所有firebase类exc。在我的注册页面中,我声明了firebase的授权人使用的字符串email

      class _RegisterState extends State<Register> {
      String = email;
错误:

 I/flutter ( 3037): Error: 'package:firebase_auth/src/firebase_auth.dart': Failed assertion: line 174 
 pos 12: 'email != null': is not true.

这里您还没有保存表单状态,所以首先将表单状态保存为

void validateAndSubmit() async {

String userId = "";

_formKey2.currentState.save();

try {
  if (_isLoginForm) {
    userId = await widget.auth.signIn(email, _password);
    print('Signed in: $userId');
  } else {
    userId = await widget.auth.signUp(email, _password);
    //widget.auth.sendEmailVerification();
    //_showVerifyEmailSentDialog();
    print('Signed up user: $userId');
  }
  setState(() {
    _isLoading = false;
  });

  if (userId.length > 0 && userId != null && _isLoginForm) {
    widget.loginCallback();
  }
}catch (e) {
  print('Error: $e');
  setState(() {
    _isLoading = false;
    _errorMessage = e.message;
    _formKey2.currentState.reset();
  });
}


 }

请添加
validateAndSubmit
函数。刚刚添加了@HemanthRaj
 I/flutter ( 3037): Error: 'package:firebase_auth/src/firebase_auth.dart': Failed assertion: line 174 
 pos 12: 'email != null': is not true.
void validateAndSubmit() async {

String userId = "";

_formKey2.currentState.save();

try {
  if (_isLoginForm) {
    userId = await widget.auth.signIn(email, _password);
    print('Signed in: $userId');
  } else {
    userId = await widget.auth.signUp(email, _password);
    //widget.auth.sendEmailVerification();
    //_showVerifyEmailSentDialog();
    print('Signed up user: $userId');
  }
  setState(() {
    _isLoading = false;
  });

  if (userId.length > 0 && userId != null && _isLoginForm) {
    widget.loginCallback();
  }
}catch (e) {
  print('Error: $e');
  setState(() {
    _isLoading = false;
    _errorMessage = e.message;
    _formKey2.currentState.reset();
  });
}


 }