我需要在整数前显示一个美元符号。我试图添加它并从中退出,但显示错误。在最后一个Text()小部件中,需要在locations [index] .amount.toString()之前添加它。我该怎么做呢?
body: Container(
child: ListView.builder(
itemCount: locations.length,
shrinkWrap: true,
itemBuilder: (context, index) {
return Padding(
padding: EdgeInsets.symmetric(vertical: 1.0, horizontal: 4.0),
child: Card(
color: (index % 2 == 0) ? greycolor : Colors.white,
child: Container(
height: 60,
padding: EdgeInsets.fromLTRB(0, 20, 0, 0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(locations[index].date,
style: TextStyle(fontSize: 20),
textAlign: TextAlign.left),
Container(
margin: EdgeInsets.only(right: 112),
child: Text(locations[index].location,
style: TextStyle(
fontSize: 20, fontWeight: FontWeight.bold),
textAlign: TextAlign.center)),
Text(locations[index].amount.toString(),
style: TextStyle(fontSize: 20),
textAlign: TextAlign.right)
],
)),
),
);
},
),
答案 0 :(得分:1)
这有效:
Text(
'\$${locations[index].amount}',
style: TextStyle(fontSize: 20),
textAlign: TextAlign.right,
);