How do you replace a listener in dart? -
i have class creates button , connects listener click event. in sub class i'd replace superclass handler. code adds listener:
row.query("[value='save']").onclick.listen(handlenewalert);
how remove existing listener?
greg's answer describes how unsubscribe event source. correct, imo bit awkward, need keep subscription instance around in case derived class wants cancel it, or need provide method on base class if want hide details.
as want replace handler, understand providing different implementation, simpler approach simlpy override handlenewalert
method in derived class.
of course, won't work if instead of method name have specified anonymous function, can't overridden, in scenario shown in example, might easier approach.
Comments
Post a Comment