![](/img/trans.png)
[英]How to add items in HistoryListTile by a button in this code? Flutter
[英]How to code add button like zoom at in Flutter
我需要实现一个像放大一样的按钮,当我们点击“+”时,值应该增加,当我们点击“-”时,值应该减少,计算值应该显示在“+”和“的中间” -”按钮上。
RawMaterialButton(
fillColor: Colors.green,
splashColor: Colors.greenAccent,
onPressed: onPressed,
shape:const StadiumBorder(),
child: Padding(
padding: const EdgeInsets.all(3.0),
child: Row(
children: <Widget>[
const Icon(
Icons.add,
color: Colors.white,
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text("ADD",
style: TextStyle(
color: Colors.white,
),
),
),
const Icon(
Icons.remove,
color: Colors.white,
)
],
),
));
**但我不知道如何创建两个不同的按钮我只需要设计部分**
在一行中,您可以使用 IconData(-)、Text(5) 和 IconData(+),例如:
Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Expanded(
child: Material(
child: IconButton(
icon: Icon(Icons.remove_circle_outline,
color: Colors.black),
onPressed: () {
_decrementValue(value);
}),
)),
Expanded(
child: Text(
'${value}',
textAlign: TextAlign.center,
)),
Expanded(
child: Material(
child: IconButton(
icon: Icon(Icons.add_circle_outline,
color: Colors.black),
onPressed: () {
_incrementValue(value);
}),
)),
],
),
)
在 _incrementValue() 和 _decrementValue() 方法中,您可以使用您的逻辑。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.