简体   繁体   English

如何增加 flutter 中的边界半径限制?

[英]how to increase the border radius limit in flutter?

I want to crop the top right corner a bit more but even on increasing the border radius.我想更多地裁剪右上角,但即使增加边框半径也是如此。 It is not exceeding the center point of the container.它不超过容器的中心点。 Can anyone tell how can i obtain design as shown in the pic.谁能告诉我如何获得如图所示的设计。

My Code:-我的代码:-

Material(
            clipBehavior: Clip.antiAlias,
            color: Colors.blue,
            shape: BeveledRectangleBorder(
              borderRadius: BorderRadius.only(
                topRight: Radius.elliptical(40,90),
              ),
            ),
            child: Container(
              height: 100,
              width: 180,
            ),
          ),

Expected:-预期的:-

在此处输入图像描述

Current One:-当前一个:-

当前一个

For custom shapes, you can define CustomClipper (you don't need any packages for that):对于自定义形状,您可以定义CustomClipper (您不需要任何包):

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: darkBlue),
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: Center(
          child: ClipPath(
            clipper: ShapeClipper(),
            child: Container(color: Colors.red, width: 300, height: 200),
          ),
        ),
      ),
    );
  }
}

class ShapeClipper extends CustomClipper<Path> {
  @override
  Path getClip(Size size) {
    return Path()
      ..lineTo(0.0, size.height)
      ..lineTo(size.width, size.height)
      ..lineTo(size.width - 100, 0.0)
      ..close();
  }

  @override
  bool shouldReclip(ShapeClipper oldClipper) => false;
}

This should cover your case, just adjust the ShapeClipper with specific values.这应该涵盖您的情况,只需使用特定值调整ShapeClipper

In case anyone else wants this, I found a way.万一其他人想要这个,我找到了一种方法。 You can use this plugin and modify your code to:-您可以使用插件并将您的代码修改为:-

Diagonal(
            clipHeight: 40,
            axis: Axis.vertical,
            position: DiagonalPosition.BOTTOM_RIGHT,
            child: Container(
              color: Colors.blue,
              height: 100,
              width: 180,
            ),
          ),

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

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