I want user to be able to jump between controls with 'Tab' in my flutter web app. I followed this post to catch the key "Tab" and to navigate to next controls.
When user presses 'Tab', cursor jumps to the next text box, but then, when user types, no letters appears in the text box.
What can be wrong?
Here is the code:
class _LoginScreenState extends State<LoginScreen> {
FocusNode _passwordFocus;
FocusNode _emailFocus;
@override
void initState() {
super.initState();
_emailFocus = FocusNode();
_passwordFocus = FocusNode();
}
@override
void dispose() {
_emailFocus.dispose();
_passwordFocus.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final TextEditingController emailController =
new TextEditingController(text: this._email);
final TextEditingController passwordController =
new TextEditingController();
return Scaffold(
appBar: AppBar(
title: Text('Sign In'),
),
body: Column(
children: <Widget>[
RawKeyboardListener(
child: TextField(
autofocus: true,
controller: emailController,
decoration: InputDecoration(
labelText: "EMail",
),
),
onKey: (dynamic key) {
if (key.data.keyCode == 9) {
FocusScope.of(context).requestFocus(_passwordFocus);
}
},
focusNode: _emailFocus,
),
TextField(
controller: passwordController,
obscureText: true,
focusNode: _passwordFocus,
decoration: InputDecoration(
labelText: "Password",
),
),
],
),
);
}
}