命名参数未定义

时间:2019-10-16 15:53:20

标签: flutter dart

我目前正在学习Flutter,并且对它很陌生。我正在尝试在默认代码的增量计数器旁边创建一个减量计数器。我为减少写了另一个空,并写了相同的代码来增加(除了增加),但是它给出了错误:

  

未定义命名参数“ bulutunKatiliRota”。   尝试将名称更正为现有的命名参数,或使用该名称定义新参数。dart(undefined_named_pa​​rameter)

代码(我只写我添加的代码):

void _decreaseCounter(){
    setState(() {
      _counter--;
    });
  }

bulutunKatiliRota: FloatingActionButton(
        onPressed: _decreaseCounter,
        tooltip: 'Decrease',
        child: Icon(Icons.delete)
      )

1 个答案:

答案 0 :(得分:1)

为此替换您的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),
    ),
  ],
)
相关问题