【发布时间】:2020-11-16 13:59:19
【问题描述】:
class TransactionWidget extends StatelessWidget {
final List<Transaction> _transaction;
TransactionWidget(this._transaction);
@override
Widget build(BuildContext context) {
return Container(
height: 500,
child: ListView.builder(
itemBuilder: (ctx, index) {
return Card(
child: Row(
children: <Widget>[
Container(
margin: EdgeInsets.symmetric(horizontal: 15, vertical: 10),
child: Text(
'\$${_transaction[index].amount.toString()}',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20,
color: Colors.blue),
),
decoration: BoxDecoration(
border: Border.all(width: 2, color: Colors.lightBlue)),
padding: EdgeInsets.all(8),
), // amount ICON (Left)
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
_transaction[index].title,
style:
TextStyle(fontWeight: FontWeight.bold, fontSize: 17),
), // Text Title
Text(
DateFormat('dd-MM-yyyy').format(_transaction[index].date),
style: TextStyle(fontSize: 13, color: Colors.grey),
), // Text Date
],
) // Text of Title and Date
],
));
},
itemCount: _transaction.length,
));
}
}
我正在构建一个显示用户输入的交易列表的颤振应用程序。以下代码用于构建和显示多个事务,但是每当我打开键盘输入新事务时,就会发生溢出错误。在交易列表上方,我添加了“卡片”小部件,该小部件接受用户输入并添加新交易。 The screenshot of the app
【问题讨论】: