我想要实现一个带有文本框的ListTile,类似于iOS中的静态表格视图,这样用户就可以点击它并直接编辑文本。
无论如何,在Flutter中如何实现呢?
为了未来可能遇到此问题的人们,这里提供解决方案:
new ListTile(
title: Text('签名'),
trailing: new Container(
width: 150.0,
child: new Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
new Expanded(
flex: 3,
child: new TextField(
textAlign: TextAlign.end,
decoration:
new InputDecoration.collapsed(hintText: '$userAddr'),
),
),
new Expanded(
child: new IconButton(
icon: new Icon(Icons.chevron_right),
color: Colors.black26,
onPressed: () {},
),
)
],
),
),
),
始终为文本字段使用展开功能。
目前在Flutter的V1.12版本中,您可以在标题中放置一行并填充它
ListTile(
title: Row(
children: <Widget>[
Expanded(
child: Text('签名')
),
Expanded(
child: TextField(
// your TextField's Content
),
),
],
),
trailing: IconButton(
icon: new Icon(Icons.chevron_right),
color: Colors.black26,
onPressed: () {},
)
),
ListTile(
title: Text("Price"),
trailing: SizedBox(
width: MediaQuery.of(context).size.width * 0.2,
child: TextField(),
),
),