相关疑难解决方法(0)

Fat Arrow notation with curly braces in setState Dart/Flutter

I am very new to Dart/Flutter and I have a confusion regarding the => notation. The documentation says that the => notation is used as a shorthand to return a single expression.

bool isNoble(int atomicNumber) => _nobleGases[atomicNumber] != null;

My doubt comes when I am trying to set state in a flutter application.

RaisedButton(
  onPressed: () => {
    setState(() {
      print('hello');
      _products.add('More stuff');
    })
  },
  child: Text('Add Product'),
),
Run Code Online (Sandbox Code Playgroud)

Now when i change the setState method with => notation

RaisedButton( …
Run Code Online (Sandbox Code Playgroud)

dart flutter

6
推荐指数
2
解决办法
497
查看次数

标签 统计

dart ×1

flutter ×1