I have a Form with quite a few TextFormFields inside it and (for now) a single DropDownButton.
When I tap into one of the TextFormFields, the keyboard flashes but will not stay up. The only workaround I have found is to start typing on my computer's keyboard to get the phone keyboard to pop up on its own - obviously not typing into anywhere - and then, while the keyboard is already up, tap into the TextFormField and then I am able to enter in text, but as soon as I tap out out of that field, the entered text disappears. This bandaid is ineffective on all fields other than Name, because their keyboardTypes are number pads. So, since typing neither letters or numbers summons this keyboard on the phone, it is impossible to get the keyboard for these fields to materialize.
I'm sure that the Form is the issue because with the same layering, if I change the Padding's child to go directly to the same ListView, all of the TextFormField issues go away.
I chose not to include the relevant code for my DropDownButton issue, because it is likely unrelated, since it is the only problem that does not resolve when I temporarily remove the Form widget.
With temporary workaround, entered text still will not remain after exiting field
DropDownButton wont display selected value
class NewPage extends MaterialPageRoute<Null>{
final formKey = GlobalKey<FormState>();
String _name;
void _submit(){
final form = formKey.currentState;
if(form.validate()){
form.save();
print("$_name");
}
}
final name = TextFormField(
//all other TextFormFields are declared as name is
validator: (val) =>
val.isEmpty? "Name can't be empty.': null,
onSaved: (val) => _name = val,
decoration: InputDecoration(
labelText: "Name",
labelStyle: TextStyle(
fontSize: 20.0,
),
contentPadding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 12.0),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(20.0),
)
)
);
final age = TextFormField(
keyboardType: TextInputType.number,
validator: null,
decoration: InputDecoration(
labelText: "Age",
labelStyle: TextStyle(
fontSize: 20.0,
),
contentPadding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 12.0),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(20.0),
)
),
);
return Scaffold(
body: Padding(
padding: EdgeInsets.symmetric(horizontal: 20.0),
child: new Form(
key: formKey,
child: new ListView(
children: <Widget> [
SizedBox(height: 100.0),
name,
SizedBox(height: 20.0),
new Text("Sex:"),
sex,
SizedBox(height: 20.0),
age,
//and so on
new RaisedButton(
onPressed: _submit,
child: new Text("Go"),
),
],
),
),
),
);
}