getOuterPath method

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

生成外轮廓路径

  1. 创建圆角矩形主体
  2. 根据offset/position计算箭头位置
  3. 组合路径形成对话框气泡形状 @return 包含箭头的气泡路径

Implementation

@override

/// 生成外轮廓路径
///
/// 1. 创建圆角矩形主体
/// 2. 根据offset/position计算箭头位置
/// 3. 组合路径形成对话框气泡形状
/// @return 包含箭头的气泡路径
Path getOuterPath(Rect rect, {TextDirection? textDirection}) {
  Path path1 = PathExtra.rect(Rect.fromLTWH(0, 0, rect.width, rect.height));
  double n = (rect.height - cutSize / 2) / (3 * cutSize / 2);
  int np = n.toInt();
  for (int i = 1; i <= np; ++i) {
    Path oPath1 = PathExtra.cycle(
        center: Offset(0, cutSize * 1.5 * i), radius: cutSize);
    path1 = path1.hole(oPath1);
    Path oPath2 = PathExtra.cycle(
        center: Offset(rect.width, cutSize * 1.5 * i), radius: cutSize);
    path1 = path1.hole(oPath2);
  }
  return path1.shift(Offset(rect.left, rect.top));
}