我目前正在学习Flutter,但我对此很陌生。我正在尝试在默认代码的增量计数器旁边创建一个减量计数器。我写了另一个减少的空位,并写了相同的代码来增加(除了增加),但它给出了错误:
未定义命名参数'bulutunKatiliRota'。尝试将名称更正为现有的命名参数,或使用该名称定义新参数。dart(undefined_named_parameter)
代码(我只写我添加的代码):
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),
),
],
)