问题描述
我在 Flutter 中创建了一个自定义形状。我面临的问题是,我已使用 ShapeBorder 并将其分配为 Card 。我想在绘制的小部件内对齐我的文本,但目前它还在考虑将我们的视图作为小部件的一部分。
这是我使用的代码:
Align(
child: Container(
height: 250,width: 300,child: Card(
clipBehavior: Clip.hardEdge,shape: Shape1(factor: 0.8),child: Container(
padding: EdgeInsets.only(left: 16.0),child: Align(
alignment: Alignment.bottomLeft,child: Text(
'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry standard dummy text ever since the 1500s,when an unkNown printer took a galley of type and scrambled it to make a type specimen book',// style: textStyleNotoSansRegular(),),widthFactor: 0.8,
形状类别:
class Shape1 extends ShapeBorder {
final double factor;
Shape1({this.factor});
@override
EdgeInsetsGeometry get dimensions => EdgeInsets.zero;
@override
Path getInnerPath(Rect rect,{TextDirection textDirection}) => null;
@override
Path getouterPath(Rect rect,{TextDirection textDirection}) {
return Path()
..moveto(rect.bottomLeft.dx,rect.bottomLeft.dy)
..relativeLineto(rect.width * factor,0)
..lineto(rect.topRight.dx,rect.topRight.dy)
..relativeLineto(rect.width * -factor,0)
..close();
}
@override
void paint(Canvas canvas,Rect rect,{TextDirection textDirection}) {
var path = Path()
..moveto(rect.bottomLeft.dx,0)
..close();
var BoxPainter = Paint();
BoxPainter.strokeWidth = 5;
BoxPainter.color = Colors.yellow;
BoxPainter.style = PaintingStyle.stroke;
canvas.drawPath(path,BoxPainter);
}
@override
ShapeBorder scale(double t) => null;
}
当前结果:
预期结果:
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)