我目前正在学习Flutter,并且对它很陌生。我正在尝试在默认代码的增量计数器旁边创建一个减量计数器。我写了另一个减少的空位,并写了相同的代码来增加(除了增加),但它给出了错误:
代码(我只写我添加的代码):
void _decreaseCounter(){
setState(() {
_counter--;
});
}
bulutunKatiliRota: FloatingActionButton(
onPressed: _decreaseCounter,
tooltip: 'Decrease',
child: Icon(Icons.delete)
)
最佳答案
将此替换为floatingActionButton
:
floatingActionButton: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
FloatingActionButton( // first FAB to perform decrement
onPressed: _decrementCounter,
child: Icon(Icons.delete),
),
FloatingActionButton( // second FAB to perform increment
onPressed: _incrementCounter,
child: Icon(Icons.add),
),
],
)
关于flutter - 命名参数未定义,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/58417298/