Container constructor

Container({
  1. BloomNode? child,
  2. EdgeInsets? padding,
  3. EdgeInsets? margin,
  4. Color? color,
  5. num? width,
  6. num? height,
  7. Alignment? alignment,
  8. BoxDecoration? decoration,
  9. num? minWidth,
  10. num? maxWidth,
  11. num? minHeight,
  12. num? maxHeight,
})

Creates a box with dimensions, spacing, alignment, and decoration.

Container(color: Colors.blue, child: StyledText('Hi'));

Implementation

Container(
    {BloomNode? child,
    EdgeInsets? padding,
    EdgeInsets? margin,
    Color? color,
    num? width,
    num? height,
    Alignment? alignment,
    BoxDecoration? decoration,
    num? minWidth,
    num? maxWidth,
    num? minHeight,
    num? maxHeight})
    : super('div',
          children: child == null ? const [] : [child],
          style: _css([
            if (padding != null) 'padding: ${padding.css}',
            if (margin != null) 'margin: ${margin.css}',
            if (color != null) 'background-color: ${color.css}',
            if (width != null) 'width: ${_px(width)}',
            if (height != null) 'height: ${_px(height)}',
            if (alignment != null)
              'display: grid; place-items: ${_place(alignment)}',
            if (minWidth != null) 'min-width: ${_px(minWidth)}',
            if (maxWidth != null) 'max-width: ${_px(maxWidth)}',
            if (minHeight != null) 'min-height: ${_px(minHeight)}',
            if (maxHeight != null) 'max-height: ${_px(maxHeight)}',
            decoration?.css ?? '',
          ]));