render method

  1. @override
HTMLSelectElement render()
override

Creates an HTML Element represention of Component.

Implementation

@override
HTMLSelectElement render() {
  final element = super.render() as HTMLSelectElement;

  for (final option in options) {
    final optionElement = HTMLOptionElement()
      ..value = option.value
      ..appendChild(option.child.render());

    if (option.value == defaultValue) {
      optionElement.selected = true;
    }

    element.append(optionElement);
  }

  if (onSelect != null) {
    element.onChange.listen((event) {
      onSelect!(element.value);
    });
  }

  return element;
}