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 sparkline = widget as Sparkline;
  // For sparkline, standard orientation rules apply
  final isHorizontal =
      sparkline.direction == ProgressDirection.bottomToTop ||
      sparkline.direction == ProgressDirection.topToBottom;

  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()));
}