我想要得到的是,当我以应该可以进入另一页的形式输入ID和密码时。但是,当我按Submit时,什么也没发生。我得到的错误是使用不相关类型的引用进行的Equality运算符==
调用。有什么办法解决这个问题?
Form(
key: _formKey,
child: Column(children: <Widget>[
TextFormField(
controller: nameController,
decoration: InputDecoration(labelText: 'Id'),
keyboardType: TextInputType.emailAddress,
validator: (value) {
if (value.isEmpty) {
return 'Enter id';
}
return null;
},
),
TextFormField(
controller: passwordController,
decoration: InputDecoration(labelText: 'Password'),
obscureText: true,
validator: (value) {
if (value.isEmpty) {
return 'invalid password';
}
return null;
},
),
SizedBox(height: 30),
RaisedButton(
child: Text('Submit'),
onPressed: () {
if (nameController == //i am getting a blue underline over here
FirebaseFirestore.instance
.collection("proddecAdmin")
.doc("1")
.set({'Id': ''}) &&
passwordController == //i am getting a blue underline over here
FirebaseFirestore.instance
.collection("proddecAdmin")
.doc("1")
.set({
'password': '',
})) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ProfilePage()),
);
}
},
答案 0 :(得分:0)
nameController和密码控制器只是TextEditingController
实例。您要与存储在控制器中的值进行比较。例如
nameController.value.text == ''
passwordController.value.text == ''