constraints method

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

Implementation

ConstrainedBox constraints(
    {double? maxWidth, double? maxHeight, double? minWidth, double? minHeight}) {
  BoxConstraints constraints = BoxConstraints(
      maxWidth: maxWidth ?? double.infinity,
      maxHeight: maxHeight ?? double.infinity,
      minWidth: minWidth ?? 0,
      minHeight: minHeight ?? 0);

  if (this is ConstrainedBox) {
    var thisConstraints = (this as ConstrainedBox).constraints;
    constraints =
        maxWidth?.let((it) => thisConstraints.copyWith(maxWidth: maxWidth)) ?? thisConstraints;
    constraints =
        maxHeight?.let((it) => thisConstraints.copyWith(maxWidth: maxWidth)) ?? thisConstraints;
    constraints =
        minWidth?.let((it) => thisConstraints.copyWith(maxWidth: maxWidth)) ?? thisConstraints;
    constraints =
        minHeight?.let((it) => thisConstraints.copyWith(maxWidth: maxWidth)) ?? thisConstraints;
  }
  return ConstrainedBox(constraints: constraints, child: this);
}