简体   繁体   English

如何获得下图中给出的边界半径。 #扑

[英]How to get the Border-Radius given in the following image . #flutter

enter image description here在此处输入图片说明

I want to obtain an inverted border-radius indicated in the following picture.我想获得下图所示的倒转边界半径。

Surround your Image widget with ClipRRect widget.用 ClipRRect 小部件包围您的图像小部件。 Specify the required border radius.指定所需的边界半径。 As we need rounded borders, we specify circular border radius using BorderRadius.circular().由于我们需要圆形边框,我们使用 BorderRadius.circular() 指定圆形边框半径。 BorderRadius.circular() takes a double value as argument. BorderRadius.circular() 将双精度值作为参数。 This double value is the border radius for all the four corners of the rectangle.这个双精度值是矩形所有四个角的边界半径。 Following is the code snippet to display an image with round corners.以下是显示带有圆角的图像的代码片段。

Example: ClipRRect( borderRadius: BorderRadius.circular(20), child: Image( image: NetworkImage( 'https://www.img/hummingbird.png'), ), ),示例:ClipRRect( borderRadius: BorderRadius.circular(20), child: Image( image: NetworkImage( 'https://www.img/hummingbird.png'), ), ),

try to reference to this code, reference :尝试参考此代码,参考

class Clipper extends CustomClipper<Path> {
  @override
  Path getClip(Size size) {
    var _height = size.height;
    var _width = size.width;

    var controlPoint1 = Offset(40, _height / 3.1);
    var controlPoint2 = Offset(_width - 40, 0);
    var endPoint = Offset(_width, _height / 2);

    var path = Path()
      ..cubicTo(controlPoint1.dx, controlPoint1.dy, controlPoint2.dx,
          controlPoint2.dy, endPoint.dx, endPoint.dy)
      ..lineTo(_width, _height)
      ..lineTo(0, _height)
      ..close();

    return path;
  }

  @override
  bool shouldReclip(CustomClipper<Path> oldClipper) => true;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM