0

I want to pass parameters onto the 'onpressed'

  • :) == official syntax
  • :( == get a void error
  • : p == is the trick I wrote, which doesn't give me an editor error,
    but a console error with setstate() after dispose() message

Is there a way to pass parameters to methods in onpressed?

// :) onPressed: (){},
// :) onPressed: _methodName,
// :( onPressed: _methodName(param),
// :p onPressed: (){_methodName(param)},

onPressed: () {
    var docId = _dataList[idx].documentID;
    setState(() { ... });
    print('delete complite');
),

cf. :( error img https://i.stack.imgur.com/DfHpu.png

Josh
  • 991
  • 6
  • 14
bora
  • 58
  • 4

1 Answers1

0

Based on the image you posted, you should do

onPressed: () => _clickDeleteIcon(_dataList[idx].documentId),
Sebastian
  • 3,666
  • 2
  • 19
  • 32