Dartpad html – how to remove event listeners on re-run?

Issue In Dartpad with html (https://dartpad.dev/html), I am experimenting with the following code snippet: import ‘dart:html’; void main() { final header = querySelector(‘#header’); header?.text = "Hello, World!"; var streamobject = document.onSelectionChange.listen(handleSelectionChange); // streamobject.cancel() when re-run } void handleSelectionChange(Event e) {

Continue reading