Closed thosakwe closed 7 years ago
For this to work, there needs to be some sort of isomorphic dom wrapper library.
Something like this would be nice, and make it easy to close event subscriptions...
abstract class AbstractElement {
Iterable<AbstractElement> get children;
AbstractElement get parent;
AbstractElement querySelector(String query);
Iterable<AbstractElement> querySelectorAll(String query);
void listen<T>(String eventName, void callback(T event));
Future close();
}
import 'dart:html' as html;
class CheckboxWidget extends Widget<bool> {
@override
void afterRender(AbstractElement $el, State<bool> state) {
$el.listen<html.Event>('click', (html.Event e) {
state.set('value', !state['value']);
});
}
@override
Node render(State<bool> state) {
return input(type: 'checkbox', checked: state['value']);
}
}
Have a custom renderer for browser and io