我实现了Firebase Flutter登录,并从here中获取了代码。
class _EmailPasswordFormState extends State<_EmailPasswordForm> {
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
final TextEditingController _emailController = TextEditingController();
final TextEditingController _passwordController = TextEditingController();
bool _success;
String _userEmail;
@override
Widget build(BuildContext context) {
return Form(
key: _formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
child: const Text('Test sign in with email and password'),
padding: const EdgeInsets.all(16),
alignment: Alignment.center,
),
TextFormField(
controller: _emailController,
decoration: const InputDecoration(labelText: 'Email'),
validator: (String value) {
if (value.isEmpty) {
return 'Please enter some text';
}
return null;
},
),
TextFormField(
controller: _passwordController,
decoration: const InputDecoration(labelText: 'Password'),
validator: (String value) {
if (value.isEmpty) {
return 'Please enter some text';
}
return null;
},
),
Container(
padding: const EdgeInsets.symmetric(vertical: 16.0),
alignment: Alignment.center,
child: RaisedButton(
onPressed: () async {
if (_formKey.currentState.validate()) {
_signInWithEmailAndPassword();
}
},
child: const Text('Submit'),
),
),
Container(
alignment: Alignment.center,
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
_success == null
? ''
: (_success
? 'Successfully signed in ' + _userEmail
: 'Sign in failed'),
style: TextStyle(color: Colors.red),
),
)
],
),
);
}
我在两个textInputAction: TextInputAction.next
中添加了textInputAction: TextInputAction.go
和TextFormField
。键盘上的设计正在更改,但是单击时什么也没有发生。我希望在单击第二个TextFormField中的“ go”时,在第一个TextFormField中出现“ next”按钮后,按下提交按钮。
我需要实现什么?谢谢!