constraints method

  1. @widgetFactory
Widget constraints({
  1. double? minWidth,
  2. double? maxWidth,
  3. double? minHeight,
  4. double? maxHeight,
  5. BoxConstraints? constraints,
  6. bool overflow = false,
  7. AlignmentGeometry? alignment,
})

Applies additional constraints to this widget.

Implementation

@widgetFactory
Widget constraints({
  double? minWidth,
  double? maxWidth,
  double? minHeight,
  double? maxHeight,
  BoxConstraints? constraints,
  bool overflow = false,
  AlignmentGeometry? alignment,
}) {
  assert(
    overflow || alignment == null,
    'alignment can only be used with overflow',
  );
  assert(() {
    _debugCheckParameterCombinations(modifier: 'constraints', [
      {
        'minWidth': minWidth,
        'maxWidth': maxWidth,
        'minHeight': minHeight,
        'maxHeight': maxHeight,
      },
      {'constraints': constraints},
    ]);
    return true;
  }());

  if (overflow) {
    return FleetOverflowBox(
      minHeight: minHeight ?? constraints?.minHeight,
      maxHeight: maxHeight ?? constraints?.maxHeight,
      minWidth: minWidth ?? constraints?.minWidth,
      maxWidth: maxWidth ?? constraints?.maxWidth,
      alignment: alignment ?? Alignment.center,
      child: this,
    );
  } else {
    constraints ??= BoxConstraints(
      minWidth: minWidth ?? 0,
      maxWidth: maxWidth ?? double.infinity,
      minHeight: minHeight ?? 0,
      maxHeight: maxHeight ?? double.infinity,
    );
    return FleetConstrainedBox(
      constraints: constraints,
      child: this,
    );
  }
}