How to identify which button is clicked in flutter

孤人 提交于 2019-12-24 16:18:12

问题


I have 4 buttons showing a different list each time a button is clicked . How to identify which button is clicked using flutter ?


回答1:


You can assign a callback that calls a different method for each button

new FlatButton(
  child: new Text(confirmText),
  onPressed: () => onOkPressed(),
),

or you can pass a parameter

new FlatButton(
  child: new Text(confirmText),
  onPressed: () => onButtonPressed('okButton'),
),


来源:https://stackoverflow.com/questions/47588528/how-to-identify-which-button-is-clicked-in-flutter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!