问题描述
我是 Flutter 的新手,正在从事布局设计。
如何制作像下面这样的自定义形状,末端有两个锋利的边缘?
我可以使用 ShapeBorder
添加一个。
任何资源将不胜感激,谢谢。
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 (将#修改为@)