onLayout method

  1. @override
void onLayout(
  1. double left,
  2. double top,
  3. double right,
  4. double bottom,
)
override

Implementation

@override
void onLayout(double left, double top, double right, double bottom) {
  double itemAngle = 360 / props.indicator.length;
  if (!props.clockwise) {
    itemAngle *= -1;
  }
  double radius = width / 2;
  num oa = props.offsetAngle;
  _axisMap.forEach((key, value) {
    double angle = oa + value.index * itemAngle;
    Offset o = circlePoint(radius, angle);
    LineProps layoutProps = LineProps(Rect.zero, Offset.zero, o);
    value.layout(layoutProps, collectChildData(value.index));
  });

  double radiusItem = radius / props.splitNumber;
  int axisCount = props.indicator.length;

  ///Shape
  _shapePathList.clear();
  for (int i = 0; i < props.splitNumber; i++) {
    double r = radiusItem * (i + 1);
    Path path;
    if (props.shape == RadarShape.circle) {
      path = Circle(r: r).path(false);
    } else {
      path = PositiveShape(r: r, count: axisCount).path(false);
    }
    _shapePathList.add(path);
  }

  ///布局孩子
  for (var child in children) {
    child.layout(0, 0, width, height);
  }
}