hiearchy method

Widget hiearchy(
  1. BuildContext context,
  2. Widget child
)

Builds the widget using a LayoutBuilder to adapt to the parent container's size constraints.

If no constraints are provided, it uses the suggested dimensions. The width and height are bounded by the specified boundaries.

Implementation

Widget hiearchy(BuildContext context, Widget child) {
  return LayoutBuilder(
    builder: (BuildContext context, BoxConstraints constraints) {
      final hasHeight = constraints.hasBoundedHeight;
      final hasWidth = constraints.hasBoundedWidth;
      final width = hasWidth ? constraints.maxWidth * flexWidth : suggestedWidth;
      final containerHeight = ResponsiveContainer.of(context)?.lastHeight ?? width;
      final height = hasHeight ? constraints.maxHeight * flexHeight : containerHeight * suggestedHeight;
      return SizedBox(
        width: _doBoundaries(width, boundariesWidth),
        height: _doBoundaries(height, boundariesHeight),
        child: Padding(
          padding: padding,
          child: child,
        ),
      );
    },
  );
}