Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text("Postal Code"),
TextField(
controller: controllerPostalCode,
),
// if controllerPostalCode not null
Container(
child: FutureBuilder<AddressCtrl>( //Future Builder that hold data on State and Country
future: getDataCtrl(),
builder: (context, snapshot) {
if (snapshot.hasData) {
if (snapshot.data.result == null) {
return Container();
} else {
return Container(
child: Column(
children: <Widget>[
Text("State"),
TextField(
decoration: InputDecoration(
hintText: snapshot.data.result[index].State // value will be display after user input Postal Code text field
),
),
Text("Country"),
TextField(
decoration: InputDecoration(
hintText: snapshot.data.result[index].Country // value will be display after user input Postal Code text field
),
)
],
),
);
}
}
})),
],
),
),
我想根据用户在邮政编码文本字段上输入的值自动将值输入到两个文本字段(在这种情况下:州和国家/地区),而无需单击任何按钮。我发现了很多关于这个问题的问题,但我在 Dart/Flutter 中找不到。
附加说明:State 和 Country 的值来自 REST API。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句