img function

ElementNode img({
  1. Object? key,
  2. required String src,
  3. String? alt,
  4. int? width,
  5. int? height,
  6. bool lazy = false,
  7. String? classes,
  8. Map<String, String>? style,
  9. Map<String, Attribute>? attrs,
})

Implementation

ElementNode img({
  Object? key,
  required String src,
  String? alt,
  int? width,
  int? height,
  bool lazy = false,

  String? classes,
  Map<String, String>? style,
  Map<String, Attribute>? attrs,
}) {
  return el(
    'img',
    key: key,
    classes: classes,
    style: style,
    attrs: {
      'src': StringAttribute(src),
      if (alt != null) 'alt': StringAttribute(alt),
      if (width != null) 'width': StringAttribute(width.toString()),
      if (height != null) 'height': StringAttribute(height.toString()),
      if (lazy) 'loading': StringAttribute('lazy'),
      ...?attrs,
    },
    children: const [],
  );
}