因此在我的TextFormField小部件中,我已将TextInputAction设置为TextInputAction.next,还定义了focusNodes和onFieldSubmitted回调。
文本字段之一:
TextFormField(
keyboardType: TextInputType.number,
maxLength: 2,
validator: (value)=> value.isEmpty ? "Birth Month" : null,
onSaved: (value)=> _birthMonth = value,
textInputAction: TextInputAction.next,
focusNode: _birthMonthFocus,
onFieldSubmitted: (v) =>FocusScope.of(context).requestFocus(_birthYearFocus)
)
上面的代码有效。但是,图标没有变化。现在,我已经在3个不同的模拟器上运行了它,而且还是一样。
答案 0 :(得分:1)
尝试此代码。
final FocusNode _nameFocus = FocusNode();
final FocusNode _id = FocusNode();
void _fieldFocusChange(
BuildContext context, FocusNode nameFocus, FocusNode passwordFocus) {
nameFocus.unfocus();
FocusScope.of(context).requestFocus(passwordFocus);
}
//下面的代码定义文本字段。
textInputAction: TextInputAction.next,
focusNode: _id,
onFieldSubmitted: (term) {
_fieldFocusChange(context, _id, _nameFocus);
},