constrained method

Widget constrained({
  1. double? minWidth,
  2. double? maxWidth,
  3. double? minHeight,
  4. double? maxHeight,
})

Implementation

Widget constrained(
    {double? minWidth,
    double? maxWidth,
    double? minHeight,
    double? maxHeight}) {
  if (this is ConstrainedBox) {
    return ConstrainedBox(
      constraints: BoxConstraints(
        minWidth: minWidth ?? (this as ConstrainedBox).constraints.minWidth,
        maxWidth: maxWidth ?? (this as ConstrainedBox).constraints.maxWidth,
        minHeight:
            minHeight ?? (this as ConstrainedBox).constraints.minHeight,
        maxHeight:
            maxHeight ?? (this as ConstrainedBox).constraints.maxHeight,
      ),
      child: (this as ConstrainedBox).child,
    );
  }
  return ConstrainedBox(
    constraints: BoxConstraints(
      minWidth: minWidth ?? 0,
      maxWidth: maxWidth ?? double.infinity,
      minHeight: minHeight ?? 0,
      maxHeight: maxHeight ?? double.infinity,
    ),
    child: this,
  );
}