最佳答案
最后根据建议使用以下内容:
class DMTextBoxOutlineBorder extends OutlineInputBorder {
@override
void paint(
Canvas canvas,
Rect rect, {
double gapStart,
double gapExtent = 0.0,
double gapPercentage = 0.0,
TextDirection textDirection,
}) {
var paint = Paint();
paint.color = Colors.black;
paint.strokeWidth = 1.0;
var startXPos = rect.bottomLeft.dx;
var startYPos = rect.bottomLeft.dy;
var height = rect.bottomLeft.dy - rect.topLeft.dy;
var width = (rect.bottomRight.dx - rect.bottomLeft.dx);
var textBox = Path();
textBox.moveTo(startXPos, startYPos);
textBox.lineTo(startXPos + width, startYPos);
......rest of the code to complete the required shape
canvas.drawPath(textBox, paint);
}
bool shouldRepaint(CustomPainter oldDelegate) {
return true;
}
}
关于Flutter:如何制作自定义形状的文本字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63526152/