Divyang Shah
Divyang Shah

Reputation: 4007

How to identify which button is clicked in flutter

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

Upvotes: 2

Views: 3335

Answers (1)

Günter Zöchbauer
Günter Zöchbauer

Reputation: 657338

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'),
),

Upvotes: 5

Related Questions