Flutter 在我的Flatter应用程序中创建新用户时,我发现firebase_auth createUserWithEmailAndPassword错误

Flutter 在我的Flatter应用程序中创建新用户时,我发现firebase_auth createUserWithEmailAndPassword错误,flutter,flutter-dependencies,Flutter,Flutter Dependencies,我正在创建一个博客应用程序,在创建新用户时出现以下错误 我/弗利特(1603):'file:///C:/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.8.4+5/lib/src/firebase_auth.dart':失败的断言:第103行位置12:“电子邮件!”null”:不正确 当我想要在我的颤振应用程序中创建新用户时,上面的消息会显示在终端中 下面是创建帐户页面的代码,我在该页面中使用UserManagement()函

我正在创建一个博客应用程序,在创建新用户时出现以下错误

我/弗利特(1603):'file:///C:/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.8.4+5/lib/src/firebase_auth.dart':失败的断言:第103行位置12:“电子邮件!”null”:不正确

当我想要在我的颤振应用程序中创建新用户时,上面的消息会显示在终端中

下面是创建帐户页面的代码,我在该页面中使用UserManagement()函数在firestore中存储用户数据

Padding(
                        padding:
                            const EdgeInsets.fromLTRB(25.0, 10.0, 25.0, 10.0),
                        child: TextFormField(
                          decoration: InputDecoration(
                              labelText: "E-mail",
                              border: OutlineInputBorder(
                                  gapPadding: 10.0,
                                  borderRadius: BorderRadius.circular(30.0))),
                          onSaved: (value) {
                            setState(() {
                              _email = value;
                            });
                          },),
                      ),
                      Padding(
                        padding:
                            const EdgeInsets.fromLTRB(25.0, 10.0, 25.0, 10.0),
                        child: TextFormField(
                          obscureText: true,
                          decoration: InputDecoration(
                              labelText: "Password",
                              border: OutlineInputBorder(
                                  gapPadding: 10.0,
                                  borderRadius: BorderRadius.circular(30.0))),
                                   onSaved: (value) {
                            setState(() {
                              _password = value;
                            });
                          },
                ),
              ),
              Container(
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    StreamBuilder<Object>(
                        stream: null,
                        builder: (context, snapshot) {
                          return SizedBox(
                              width: 367.0,
                              height: 60.0,
                              // Padding(
                              //   padding: const EdgeInsets.all(8.0),
                              child: RaisedButton(
                                child: Text("Next",
                                    style: TextStyle(
                                        color: Colors.white,
                                        fontWeight: FontWeight.w300)),
                                color: Colors.black54,
                                onPressed: () {
                                  if (_formkey.currentState
                                      .validate()) {
                                        FirebaseAuth.instance.createUserWithEmailAndPassword(
                                          email: _email,
                                          password: _password,
                                        ).then((signedInUser){
                                          UserManagement().storeNewUser(signedInUser, context);

                                        }).catchError((e){
                                          print(e);
                                        });
填充(
衬垫:
LTRB的常数边集(25.0,10.0,25.0,10.0),
子项:TextFormField(
装饰:输入装饰(
labelText:“电子邮件”,
边框:大纲输入边框(
gapPadding:10.0,
边界半径:边界半径。圆形(30.0)),
已保存:(值){
设置状态(){
_电子邮件=价值;
});
},),
),
填充物(
衬垫:
LTRB的常数边集(25.0,10.0,25.0,10.0),
子项:TextFormField(
蒙昧文字:对,
装饰:输入装饰(
labelText:“密码”,
边框:大纲输入边框(
gapPadding:10.0,
边界半径:边界半径。圆形(30.0)),
已保存:(值){
设置状态(){
_密码=值;
});
},
),
),
容器(
子:列(
mainAxisAlignment:mainAxisAlignment.center,
儿童:[
StreamBuilder(
流:空,
生成器:(上下文,快照){
返回大小框(
宽度:367.0,
身高:60.0,
//填充物(
//填充:常数边集全部(8.0),
孩子:升起按钮(
子项:文本(“下一步”,
样式:TextStyle(
颜色:颜色,白色,
fontWeight:fontWeight.w300)),
颜色:颜色。黑色54,
已按下:(){
如果(_formkey.currentState
.validate()){
FirebaseAuth.instance.createUserWithEmailAndPassword(
电子邮件:_电子邮件,
密码:_密码,
).然后((已签名用户){
UserManagement().storeNewUser(SignedUser,上下文);
}).catchError((e){
印刷品(e);
});
下面是UserManagement()函数的代码

类用户管理{
storeNewUser(用户,上下文){
Firestore.instance.collection('/users')。添加({
“电子邮件”:user.email,
“uid”:user.uid,
}).然后((值){
StreamBuilder(
流:空,
生成器:(上下文,快照){
Navigator.of(context.pop();
导航器。推(
context,materialpage(builder:(context)=>Desc());
});
}).catchError((e){
印刷品(e);
});
}
}

您是否将字段包装在表单中?
class UserManagement {
  storeNewUser(user, context) {
    Firestore.instance.collection('/users').add({
      'email': user.email,
      'uid': user.uid,
    }).then((value) {
      StreamBuilder<Object>(
          stream: null,
          builder: (context, snapshot) {
            Navigator.of(context).pop();
            Navigator.push(
                context, MaterialPageRoute(builder: (context) => Desc()));
          });
    }).catchError((e) {
      print(e);
    });
  }
}