Firebase 吸气剂';用户名';被调用为空

Firebase 吸气剂';用户名';被调用为空,firebase,flutter,dart,Firebase,Flutter,Dart,对null调用了getter“username” class Register extends StatefulWidget { final User user; Register({this.user}); @override RegisterState createState() => RegisterState(); } class RegisterState extends State<Register> { final User user; Regi

对null调用了getter“username”

 class Register extends StatefulWidget {

 final User user;
 Register({this.user});

 @override
 RegisterState createState() => RegisterState();
}


class RegisterState extends State<Register> {
final User user;
RegisterState({this.user});

FirestoreService fireServ = new FirestoreService();

TextEditingController _userNameController;
TextEditingController _userEmailController;
TextEditingController _userPasswordController;
TextEditingController _userMobileController;
TextEditingController _userLocationController;
TextEditingController _userBdController;



@override
 void initState() {
super.initState();
_userNameController = new TextEditingController(text:     '     ${this.user.username}');
_userEmailController = new TextEditingController(text: widget.user.useremail);
_userPasswordController = new TextEditingController(text: widget.user.userpassword);
_userMobileController = new TextEditingController(text: widget.user.usermobile);
_userLocationController = new TextEditingController(text: widget.user.userlcation);
_userBdController = new TextEditingController(text: widget.user.userbd);
}

@覆盖
小部件构建(构建上下文){
//TODO:实现构建
返回脚手架(
appBar:appBar(
标题:文本(“注册页面”),
),
正文:列表视图(子项:[
容器(
孩子:表格(
key:formKey,
子:列(
子项:loginCard()+社交媒体(),
),
),
)
],)
);
}

列表登录卡(){
返回[
填充物(
填充:仅限常量边集(顶部:50),
子:堆栈(
儿童:[
容器(
填充:仅限边缘设置(顶部:20),
子:列(
儿童:[
居中(
子:容器(
宽度:330.0,
高度:500.0,
颜色:颜色。白色。不透明度(.1),
子:容器(
装饰:新盒子装饰(
颜色:颜色,白色,
borderRadius:borderRadius.all(半径圆形(10)),
boxShadow:[
箱形阴影(
颜色:颜色。黑色54,
偏移量:偏移量(2,3),
半径:10,
)
],
),
子:容器(
衬垫:
仅限边缘设置(左:20,上:40,右:15),
子:列(
crossAxisAlignment:crossAxisAlignment.start,
儿童:[
正文(
"登记册",,
样式:TextStyle(
fontWeight:fontWeight.bold,fontSize:30),
),
TextFormField(
控制器:\ u userNameController,
装饰:输入装饰(
labelText:'名称',
标签样式:文本样式(
颜色:颜色。灰色,
fontStyle:fontStyle.italic),
图标:图标(
一个人,
尺码:25,
),
hintText:'你的名字在这里',
辛茨风格:
Theme.of(context).textTheme.caption,
),
textcapitalize:textcapitalize.words,
验证器:(value)=>value.isEmpty?“名称不能是embty”:null,
onSaved:(值)=>\u userNameController.text=value,
),
TextFormField(
控制器:_userEmailController,
装饰:输入装饰(
labelText:“电子邮件”,
标签样式:文本样式(
颜色:颜色。灰色,
fontStyle:fontStyle.italic),
图标:图标(
Icons.email,
尺码:25,
),
hintText:'您的电子邮件在此',
hintStyle:TextStyle(
颜色:颜色。蓝灰色,字体大小:10),
),
键盘类型:TextInputType.emailAddress,
enableInteractiveSelection:true,
验证程序:(value)=>value.isEmpty?“电子邮件不能是embty”:null,
onSaved:(值)=>\u userEmailController.text=value,
),
TextFormField(
控制器:\ u userPasswordController,
蒙昧文字:对,
装饰:输入装饰(
labelText:“密码”,
标签样式:文本样式(
颜色:颜色。灰色,
fontStyle:fontStyle.italic),
图标:图标(
Icons.lock,
尺码:23,
),
hintText:'您的密码在此',
hintStyle:TextStyle(
颜色:颜色。蓝灰色,字体大小:10),
),
validator:(value)=>value.isEmpty?“密码不能是embty”:null,
onSaved:(value)=>\u userPasswordController.text=value,
),
TextFormField(
控制器:_userMobileController,
装饰:输入装饰(
labelText:'手机号码',
标签样式:文本样式(
颜色:颜色。灰色,
fontStyle:fontStyle.italic),
图标:图标(
Icons.lock,
尺码:23,
),
hintText:'您的号码在这里',
hintStyle:TextStyle(
颜色:颜色。蓝灰色,字体大小:10),
),
validator:(value)=>value.isEmpty?“移动设备不能是embty”:null,
onSaved:(value)=>\u userMobileController.text=value,
),
final FirebaseAuth auth = FirebaseAuth.instance;

final formKey = new GlobalKey<FormState>();

 createData() {
 fireServ.createUserList(_userNameController.text,    _userEmailController.text, _userPasswordController.text, _userMobileController.text, _userLocationController.text, _userBdController.text).then((_) {
  Navigator.pop(context);
});
void signUp() async {
if (formKey.currentState.validate()) {
  formKey.currentState.save();
  try {
    FirebaseAuth.instance
        .createUserWithEmailAndPassword(
            email: _userEmailController.text,
            password: _userPasswordController.text)
        .then((signedUser) {
      createData();
    });
  } catch (e) {
    print(e.message);
  }
}
  @override
  Widget build(BuildContext context) {
  // TODO: implement build
  return Scaffold(
  appBar: AppBar(
    title: Text('RegisterPage'),
  ),
  body: ListView(children: <Widget>[
    Container(
      child: Form(
        key: formKey,
        child: Column(
          children: loginCard() + SocialMedia(),
        ),
      ),
    )
  ],)
);
List<Widget> loginCard() {
  return [
   Padding(
    padding: const EdgeInsets.only(top: 50),
    child: Stack(
      children: <Widget>[
        Container(
          padding: EdgeInsets.only(top: 20),
          child: Column(
            children: <Widget>[
              Center(
                child: Container(
                  width: 330.0,
                  height: 500.0,
                  color: Colors.white.withOpacity(.1),
                  child: Container(
                    decoration: new BoxDecoration(
                      color: Colors.white,
                      borderRadius: BorderRadius.all(Radius.circular(10)),
                      boxShadow: [
                        BoxShadow(
                          color: Colors.black54,
                          offset: Offset(2, 3),
                          blurRadius: 10,
                        )
                      ],
                    ),
                    child: Container(
                      padding:
                          EdgeInsets.only(left: 20, top: 40, right: 15),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: <Widget>[
                          Text(
                            'Register',
                            style: TextStyle(
                                fontWeight: FontWeight.bold, fontSize: 30),
                          ),
                          TextFormField(
                            controller: _userNameController,
                            decoration: InputDecoration(
                              labelText: 'name',
                              labelStyle: TextStyle(
                                  color: Colors.grey,
                                  fontStyle: FontStyle.italic),
                              icon: Icon(
                                Icons.person,
                                size: 25,
                              ),
                              hintText: 'your name here',
                              hintStyle:
                                  Theme.of(context).textTheme.caption,
                            ),
                            textCapitalization: TextCapitalization.words,
                            validator: (value)=>value.isEmpty?'Name can\'t be embty':null,
                            onSaved: (value) => _userNameController.text = value,
                          ),
                          TextFormField(
                            controller: _userEmailController,
                            decoration: InputDecoration(
                              labelText: 'email',
                              labelStyle: TextStyle(
                                  color: Colors.grey,
                                  fontStyle: FontStyle.italic),
                              icon: Icon(
                                Icons.email,
                                size: 25,
                              ),
                              hintText: 'your email here',
                              hintStyle: TextStyle(
                                  color: Colors.blueGrey, fontSize: 10),
                            ),
                            keyboardType: TextInputType.emailAddress,
                            enableInteractiveSelection: true,
                            validator: (value)=>value.isEmpty?'Email can\'t be embty':null,
                            onSaved: (value) => _userEmailController.text = value,
                          ),
                          TextFormField(
                            controller: _userPasswordController,
                            obscureText: true,
                            decoration: InputDecoration(
                              labelText: 'password',
                              labelStyle: TextStyle(
                                  color: Colors.grey,
                                  fontStyle: FontStyle.italic),
                              icon: Icon(
                                Icons.lock,
                                size: 23,
                              ),
                              hintText: 'your password here',
                              hintStyle: TextStyle(
                                  color: Colors.blueGrey, fontSize: 10),
                            ),
                            validator: (value)=>value.isEmpty?'Password can\'t be embty':null,
                            onSaved: (value) => _userPasswordController.text = value,
                          ),
                          TextFormField(
                            controller: _userMobileController,
                            decoration: InputDecoration(
                              labelText: 'Mobile Number',
                              labelStyle: TextStyle(
                                  color: Colors.grey,
                                  fontStyle: FontStyle.italic),
                              icon: Icon(
                                Icons.lock,
                                size: 23,
                              ),
                              hintText: 'your number here',
                              hintStyle: TextStyle(
                                  color: Colors.blueGrey, fontSize: 10),
                            ),
                            validator: (value)=>value.isEmpty?'Mobile can\'t be embty':null,
                            onSaved: (value) => _userMobileController.text = value,
                          ),
                          TextFormField(
                            controller: _userLocationController,
                            decoration: InputDecoration(
                              labelText: 'Location',
                              labelStyle: TextStyle(
                                  color: Colors.grey,
                                  fontStyle: FontStyle.italic),
                              icon: Icon(
                                Icons.lock,
                                size: 23,
                              ),
                              hintText: 'your Location here',
                              hintStyle: TextStyle(
                                  color: Colors.blueGrey, fontSize: 10),
                            ),
                            validator: (value)=>value.isEmpty?'Location can\'t be embty':null,
                            onSaved: (value) => _userLocationController.text = value,
                          ),
                          TextFormField(
                            controller: _userBdController,
                            decoration: InputDecoration(
                              labelText: 'Birthday',
                              labelStyle: TextStyle(
                                  color: Colors.grey,
                                  fontStyle: FontStyle.italic),
                              icon: Icon(
                                Icons.lock,
                                size: 23,
                              ),
                              hintText: 'your number here',
                              hintStyle: TextStyle(
                                  color: Colors.blueGrey, fontSize: 10),
                            ),
                            validator: (value)=>value.isEmpty?'Mobile can\'t be embty':null,
                            onSaved: (value) => _userBdController.text = value,
                          ),
                          Container(
                            padding:
                                const EdgeInsets.only(left: 205, top: 10),
                            decoration: BoxDecoration(
                                borderRadius:
                                    BorderRadius.all(Radius.circular(20))),
                            child: Row(
                              children: <Widget>[
                                RaisedButton(
                                  child: Text(
                                    'Sign Up',
                                    style: TextStyle(color: Colors.white),
                                  ),
                                  color: Colors.orange,
                                  onPressed: () => signUp(),
                                ),
                              ],
                            ),
                          ),
                        ],
                      ),
                    ),
                  ),
                ),
              ),
            ],
          ),
        ),
      ],
    ),
  ),
];
 void main() => runApp(MaterialApp(

 home: MyApp(),

 ));


 class MyApp extends StatelessWidget {



  @override

 Widget build(BuildContext context) {

return MaterialApp(
  theme: basicTheme(),
  debugShowCheckedModeBanner: false,
  title: 'Navigation',
  routes: <String, WidgetBuilder>{
    '/Login': (BuildContext context) => Login(),
    '/Register': (BuildContext context) => Register(),
    '/Profile': (BuildContext context) => Profile(),
    '/carsPage': (BuildContext context) => carsPage(),
    '/MyAppBar': (BuildContext context) => MyAppBar(),
    '/EditProfile': (BuildContext dynamic) => EditProfile01(),
    '/GarageitemPage': (BuildContext context) => GarageitemPage(),
    '/CarItemPage': (BuildContext context) => CarItemPage(),
    '/washPagePage': (BuildContext context) => washPage(),
    '/reviewsPage': (BuildContext context) => reviewsPage(),
    '/WashItemPage': (BuildContext context) => WashItemPage(),
    '/AddGarageAds': (BuildContext context) => AddGarageAds(),
    '/garagePage': (BuildContext context) => garagePage(),
    '/AddGarageAdsFirebase': (BuildContext context) => AddGarageAdsFirebase(),
   },
   home: Login(),
  );
  }
 }