我有一个TextFormField应该接收数字的。在输入第一个数字时,它应该跳到第二个TextFormField然后到第三个 TextFormField。每个TextFormField都有FocusNode我只是不知道如何使用它的属性。我有这个
TextFormField( //First Field
autofocus: true,
focusNode: FocusNode(),
decoration: InputDecoration(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(4.0)
),
),
style: TextStyle(
color: Colors.orange,
fontSize: 15.0,
),
keyboardType:
TextInputType.number,
maxLength: 1,
),
// second Field
TextFormField(),
//third Field
Run Code Online (Sandbox Code Playgroud) 我想要一系列TextFormFields,用户可以通过在软键盘上按“下一步”(或在模拟器上测试时按硬键盘上的 Tab)来导航。我期待以下 Flutter 应用程序能够正常工作:
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'TextFormField Problem Demo',
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key}) : super(key: key);
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Test Homepage'),
),
body: Column(children: <Widget>[
TextFormField(
onFieldSubmitted: (_) => FocusScope.of(context).nextFocus(),
textInputAction: TextInputAction.next,
),
TextFormField(
onFieldSubmitted: …Run Code Online (Sandbox Code Playgroud) 当我使用 TextInputAction 并将其设置为下一个时,该按钮在我的模拟器设备上确实发生了变化,但它没有执行任何操作,用户交互不会移至下一个元素。已在 FLutter `gitHUb 页面以及聊天室中打开了一张票,但到目前为止没有任何帮助,希望继续我的训练:)