el function

ElementNode el(
  1. String tag, {
  2. Object? key,
  3. Map<String, Attribute>? attrs,
  4. String? classes,
  5. Map<String, String>? style,
  6. EventCallback? onClick,
  7. Children children = const [],
})

Implementation

ElementNode el(
  String tag, {
  Object? key,
  Map<String, Attribute>? attrs,
  String? classes,
  Map<String, String>? style,
  EventCallback? onClick,
  Children children = const [],
}) {
  final attributes = <String, Attribute>{};

  if (classes != null) {
    attributes['class'] = ClassAttribute(classes);
  }

  if (style != null) {
    attributes['style'] = StyleAttribute(style);
  }

  if (onClick != null) {
    attributes['onClick'] = EventAttribute(onClick);
  }

  if (attrs != null) {
    attributes.addAll(attrs);
  }

  return ElementNode(
    tag: tag,
    key: key,
    attributes: attributes,
    children: children,
  );
}