asBoxConstraints method

BoxConstraints asBoxConstraints(
  1. {double minExtent = 0.0,
  2. double maxExtent = double.infinity,
  3. double? crossAxisExtent}
)

Returns BoxConstraints that reflects the sliver constraints.

The minExtent and maxExtent are used as the constraints in the main axis. If non-null, the given crossAxisExtent is used as a tight constraint in the cross axis. Otherwise, the crossAxisExtent from this object is used as a constraint in the cross axis.

Useful for slivers that have RenderBox children.

Implementation

BoxConstraints asBoxConstraints({
  double minExtent = 0.0,
  double maxExtent = double.infinity,
  double? crossAxisExtent,
}) {
  crossAxisExtent ??= this.crossAxisExtent;
  switch (axis) {
    case Axis.horizontal:
      return BoxConstraints(
        minHeight: crossAxisExtent,
        maxHeight: crossAxisExtent,
        minWidth: minExtent,
        maxWidth: maxExtent,
      );
    case Axis.vertical:
      return BoxConstraints(
        minWidth: crossAxisExtent,
        maxWidth: crossAxisExtent,
        minHeight: minExtent,
        maxHeight: maxExtent,
      );
  }
}