user2070369
user2070369

Reputation: 4128

Remove onclick event from ButtonElement

I added this before. myBtn.onClick.listen((_){//some code});

Now I want to remove the event from the button, so:

How do you remove the onClick event from a ButtonElement by code? I can't find an obvious way to do it.

Thank you.

Upvotes: 3

Views: 334

Answers (1)

bbs
bbs

Reputation: 2022

The .listen() returns a subscription. Which you could store in a var and call .cancel() on.

Upvotes: 4

Related Questions