どうも、ちょげ(@chogetarou)です。
TextFormFieldのエンターキーを押した時に、自動で次のTextFormFieldにフォーカスする方法を紹介します。
方法

TextFormFieldを自動で次のTextFormFieldにフォーカスするには、引数「textInputAction」を使います。
具体的には、TextFormFieldの引数「textInputAction」にTextInputAction.nextを指定します。
TextFormField(
textInputAction: TextInputAction.next,
),
TextInputAction.nextが指定されたTextFormFieldは、エンターキーを押すと自動で次のTextFormFieldにフォーカスするようになります。
使用例
以下は、使用例です。
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
body: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextFormField(
textInputAction: TextInputAction.next,
decoration: InputDecoration(
border: OutlineInputBorder(),
),
),
SizedBox(
height: 20,
),
TextFormField(
textInputAction: TextInputAction.next,
decoration: InputDecoration(
border: OutlineInputBorder(),
),
),
SizedBox(
height: 20,
),
TextFormField(
decoration: InputDecoration(
border: OutlineInputBorder(),
),
),
],
),
),
),
);
}

[Flutter]TextFormFieldにプレースホルダーを表示するには?
TextFormFieldにプレースホルダーを表示する方法を紹介します。

[Flutter]TextFormFieldのテキストを上に寄せる方法
TextFormFieldのテキストを上に寄せる方法を紹介します。

[Flutter]TextFormFieldのテキストを縦方向で真ん中に寄せるには?
TextFormFieldのテキストを縦方向で中央に寄せる方法を紹介します。

[Flutter]TextFormFieldのプレースホルダーのテキストサイズを設定するには?
TextFormFieldで表示するプレスホルダーのテキストの大きさを設定する方法を紹介します。
コメント