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.
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?
question from:https://stackoverflow.com/questions/65843177/flutter-cupertinopicker-to-trigger-functions-inside-the-list