I am trying to trigger functions inside the List with the CupertinoPicker.
var _aa = [ () { print('hello1!'); }, () { print('hello2!'); }, () { print('hello!3'); }, ];
Trying to execute _aa's functions. However, when I try to use it inside the CupertinoPicker, I get Avoid using unnecessary statements. statement.
_aa
Avoid using unnecessary statements.
CupertinoPicker( backgroundColor: Colors.white, onSelectedItemChanged: (i) { print(i); _aa[i]; <--- error statement }, itemExtent: 32.0, children: List.generate( _aa.length, (i) { print(i); }, ), ),
How can I make this work?
List<Function> _aa = [ () { print('hello1!'); }, () { print('hello2!'); }, () { print('hello!3'); }, ];
You forgot to add .call(), like this:
onSelectedItemChanged: (i) { print(i); _aa[i].call(); },
1.4m articles
1.4m replys
5 comments
57.0k users