$img function

DOMElement $img({
  1. Object? id,
  2. Object? classes,
  3. Object? style,
  4. Map<String, String>? attributes,
  5. String? src,
  6. Future<String?>? srcFuture,
  7. String? title,
  8. Object? content,
  9. bool? hidden,
  10. bool commented = false,
})

Creates an img node.

Implementation

DOMElement $img(
    {Object? id,
    Object? classes,
    Object? style,
    Map<String, String>? attributes,
    String? src,
    Future<String?>? srcFuture,
    String? title,
    Object? content,
    bool? hidden,
    bool commented = false}) {
  var img = $tag('img',
      id: id,
      classes: classes,
      style: style,
      attributes: {
        if (src != null) 'src': src,
        if (title != null) 'title': title,
        ...?attributes
      },
      content: content,
      hidden: hidden,
      commented: commented);

  if (srcFuture != null) {
    srcFuture.then((src) {
      if (src != null) {
        img.setAttribute('src', src);
        img.runtime.setAttribute('src', src);
      }
      return src;
    });
  }

  return img;
}