【发布时间】:2021-08-04 15:17:46
【问题描述】:
我遇到了 Flutter (Dart) RenderFlex 溢出像素的问题。渲染库异常。
当键盘打开时,它会在下面显示消息:
一个 RenderFlex 在底部溢出了 45enter image description here 个像素。
如果您有任何机会需要完整的日志来帮助我,请点击此处:
@override
Widget build(BuildContext context) {
return Card(
elevation: 5,
child: Container(
margin: EdgeInsets.all(10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
TextField(
decoration: InputDecoration(labelText: 'Title'),
controller: _titleController,
onSubmitted: (_) => _submitData,
// onChanged: (val) {
// titleInput = val;
// },
),
TextField(
decoration: InputDecoration(labelText: 'Amount'),
controller: _amountController,
keyboardType: TextInputType.number,
onSubmitted: (_) => _submitData,
// onChanged: (val) => amountInput = val,
),
Container(
height: 70,
child: Row(
children: [
Expanded(
child: Text(_selectedDate == null
? "No Date Choosen!"
: 'Picked Date: ${DateFormat.yMd().format(_selectedDate)}'),
),
TextButton(
onPressed: _presentDatePicker,
child: Text(
'Choose the Date!',
style: TextStyle(
color: Theme.of(context).primaryColor,
fontWeight: FontWeight.bold),
))
],
),
),
ElevatedButton(
onPressed: _submitData,
// () {
// print(titleInput);
// print(amountInput);
// print(titleController.text);
// print(amountController.text);
// addTx(
// titleController.text, double.parse(amountController.text));
// },
child: Text(
'Add Transaction',
style: TextStyle(color: Colors.white),
),
style: ButtonStyle(
foregroundColor: MaterialStateProperty.all(Colors.purple)),
)
],
),
),
);
}
}
【问题讨论】:
-
我建议的最简单的方法是用 SingleChildScrollView 包装你的列
-
我认为 OP 需要它是可滚动的,不是吗?