微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何使用颤振制作如下所示的自定义形状?

如何解决如何使用颤振制作如下所示的自定义形状?

我是 Flutter 的新手,正在从事布局设计。

如何制作像下面这样的自定义形状,末端有两个锋利的边缘? 我可以使用 ShapeBorder 添加一个

任何资源将不胜感激,谢谢。

Custom shape image

class MessageBorder extends ShapeBorder {
  final bool usePadding;

  MessageBorder({this.usePadding = true});

  @override
  EdgeInsetsGeometry get dimensions =>
      EdgeInsets.only(bottom: usePadding ? 20 : 0);

  @override
  Path getInnerPath(Rect rect,{TextDirection textDirection}) => null;

  @override
  Path getouterPath(Rect rect,{TextDirection textDirection}) {
    rect = Rect.fromPoints(rect.topLeft,rect.bottomright - Offset(0,20),);
    return Path()
      ..addRRect(RRect.fromrectAndRadius(rect,Radius.circular(0)))
      ..moveto(0,rect.bottomCenter.dy)
      ..relativeLineto(0,20)
      ..relativeLineto(20,-20)
      ..close();
  }

  @override
  void paint(Canvas canvas,Rect rect,{TextDirection textDirection}) {}

  @override
  ShapeBorder scale(double t) => this;
} 

用法

Container(
    height: 64,decoration: Shapedecoration(
        color: Colors.green,shape: MessageBorder()),alignment: Alignment.centerRight,padding: EdgeInsets.only(right: 8),),

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。