未定义命名参数

问题描述 投票:0回答:1

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

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

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

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

bulutunKatiliRota: FloatingActionButton(
        onPressed: _decreaseCounter,
        tooltip: 'Decrease',
        child: Icon(Icons.delete)
      )
flutter dart
1个回答
0
投票

用此替换您的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),
    ),
  ],
)
© www.soinside.com 2019 - 2024. All rights reserved.