美文网首页flutter
Flutter之ClipPath组件

Flutter之ClipPath组件

作者: 习惯了_就好 | 来源:发表于2019-03-27 17:28 被阅读1次
/**
 * 路径裁剪
 *
 * ClipPath({
 * Key key,
 * this.clipper, //裁剪路径
 * this.clipBehavior = Clip.antiAlias,
 * Widget child
 * })
 */
class TriangleCliper extends CustomClipper<Path> {
  //获取裁剪范围
  @override
  Path getClip(Size size) {
    //左上角为(0,0)
    var path = Path();
    path.moveTo(50.0, 50.0);//起始点
    path.lineTo(50.0, 0);//(50.0,50.0)->(50.0, 0)
    path.lineTo(100.0, 100.0);//(50.0,0)->(100.0, 100.0)
    path.close();//
    return path;
  }

  //是否重新裁剪
  @override
  bool shouldReclip(CustomClipper<Path> oldClipper) {
    return true;
  }

}


body: Center(
            child: ClipPath(
              clipper: TriangleCliper(),
              child: Image.asset(
                "images/app.png",
                width: 100.0,
                height: 100.0,
                fit: BoxFit.cover,
              ),
            ),
          )

相关文章

网友评论

    本文标题:Flutter之ClipPath组件

    本文链接:https://www.haomeiwen.com/subject/quktbqtx.html