I want to do something like the following:
void handleClick(){
//do stuff
}
void addHandlerToButton(){
window.document.query('#somebutton').on.click.add(handleClick);
}
Dart editor’s static checking reports '() -> void' is not assignable to 'EventListener'
I have a feeling I’m missing something really obvious.
Click handlers gets the click event passed as a argument (so you for example can get the screen coordiantes, target element etc.). So your handler method signature must be
The error you are reciving is actually telling you that (although in a cryptic way):
Here EventListener is basically any function type with signature void handle(Event event) so the function you add with on.click.add must match this signature.