rect function

Component rect(
  1. List<Component> children, {
  2. String? x,
  3. String? y,
  4. String? width,
  5. String? height,
  6. Color? fill,
  7. Color? stroke,
  8. String? strokeWidth,
  9. Key? key,
  10. String? id,
  11. String? classes,
  12. Styles? styles,
  13. Map<String, String>? attributes,
  14. Map<String, EventCallback>? events,
})

The <rect> element is a basic SVG shape that draws rectangles, defined by their position, width, and height. The rectangles may have their corners rounded.

  • x: The x coordinate of the rect.
  • y: The y coordinate of the rect.
  • width: The width of the rect.
  • height: The height of the rect.
  • fill: The color (or gradient or pattern) used to paint the shape.
  • stroke: The color (or gradient or pattern) used to paint the outline of the shape.
  • strokeWidth: The width of the stroke to be applied to the shape.

Implementation

Component rect(List<Component> children,
    {String? x,
    String? y,
    String? width,
    String? height,
    Color? fill,
    Color? stroke,
    String? strokeWidth,
    Key? key,
    String? id,
    String? classes,
    Styles? styles,
    Map<String, String>? attributes,
    Map<String, EventCallback>? events}) {
  return DomComponent(
    tag: 'rect',
    key: key,
    id: id,
    classes: classes,
    styles: styles,
    attributes: {
      ...attributes ?? {},
      if (x != null) 'x': x,
      if (y != null) 'y': y,
      if (width != null) 'width': width,
      if (height != null) 'height': height,
      if (fill != null) 'fill': fill.value,
      if (stroke != null) 'stroke': stroke.value,
      if (strokeWidth != null) 'stroke-width': strokeWidth,
    },
    events: events,
    children: children,
  );
}