getPath method

  1. @override
Path getPath(
  1. Rect rect, {
  2. TextDirection? textDirection,
})
override

Implementation

@override
Path getPath(Rect rect, {TextDirection? textDirection}) {
  final Rect(:left, :top, :width, :height, :isEmpty) = rect;

  if (isEmpty || width <= 0.0 || height <= 0.0) return Path();

  var scaleX = width;
  var scaleY = height;
  if (width <= height) {
    scaleY = squash * height + (1.0 - squash) * width;
  } else {
    scaleX = squash * width + (1.0 - squash) * height;
  }

  final matrix = Matrix4.identity()
    ..translateByDouble(
      left + (width - scaleX) / 2.0,
      top + (height - scaleY) / 2.0,
      0.0,
      1.0,
    )
    ..scaleByDouble(scaleX, scaleY, 1.0, 1.0);
  return path.transform(matrix.storage);
}