performLayout method

  1. @override
Size performLayout(
  1. BoxConstraints constraints
)
override

Hook for subclasses to perform layout within the given constraints.

Implementation

@override
Size performLayout(BoxConstraints constraints) {
  final progress = widget as LinearProgressIndicator;
  final isHorizontal =
      progress.direction == ProgressDirection.leftToRight ||
      progress.direction == ProgressDirection.rightToLeft;

  double w = constraints.maxWidth == BoxConstraints.infinity
      ? (isHorizontal ? 20 : 1)
      : constraints.maxWidth.toDouble();
  double h = constraints.maxHeight == BoxConstraints.infinity
      ? (isHorizontal ? 1 : 20)
      : constraints.maxHeight.toDouble();

  return constraints.constrain(Size(w.floor(), h.floor()));
}