そういう機能を持っていないので、既存機能を使う限りはあきらめるしかないです。
可能な方法としては、TableBorderの派生を作り、その中のpaintでindent/endIndentを使った描画をするといったものです。
例えば以下の様なもの。
dart
1class CustomBorder extends TableBorder {
2 const CustomBorder({
3 super.top = BorderSide.none,
4 super.right = BorderSide.none,
5 super.bottom = BorderSide.none,
6 super.left = BorderSide.none,
7 super.horizontalInside = BorderSide.none,
8 super.verticalInside = BorderSide.none,
9 super.borderRadius = BorderRadius.zero,
10 this.indent,
11 this.endIndent,
12 });
13
14 final double? indent;
15 final double? endIndent;
16
17 @override
18 void paint(Canvas canvas, Rect rect,
19 {required Iterable<double> rows, required Iterable<double> columns}) {
20 if (indent == null && endIndent == null) {
21 super.paint(canvas, rect, rows: rows, columns: columns);
22 } else {
23 assert(rows.isEmpty || (rows.first >= 0.0 && rows.last <= rect.height));
24 assert(columns.isEmpty ||
25 (columns.first >= 0.0 && columns.last <= rect.width));
26
27 if (columns.isNotEmpty || rows.isNotEmpty) {
28 final Paint paint = Paint();
29 final Path path = Path();
30
31 if (columns.isNotEmpty) {
32 switch (verticalInside.style) {
33 case BorderStyle.solid:
34 paint
35 ..color = verticalInside.color
36 ..strokeWidth = verticalInside.width
37 ..style = PaintingStyle.stroke;
38 path.reset();
39 for (final double x in columns) {
40 path.moveTo(rect.left + x, rect.top + indent!);
41 path.lineTo(rect.left + x, rect.bottom - endIndent!);
42 }
43 canvas.drawPath(path, paint);
44 break;
45 case BorderStyle.none:
46 break;
47 }
48 }
49
50 if (rows.isNotEmpty) {
51 switch (horizontalInside.style) {
52 case BorderStyle.solid:
53 paint
54 ..color = horizontalInside.color
55 ..strokeWidth = horizontalInside.width
56 ..style = PaintingStyle.stroke;
57 path.reset();
58 for (final double y in rows) {
59 path.moveTo(rect.left + indent!, rect.top + y);
60 path.lineTo(rect.right - endIndent!, rect.top + y);
61 }
62 canvas.drawPath(path, paint);
63 break;
64 case BorderStyle.none:
65 break;
66 }
67 }
68 }
69 if (!isUniform || borderRadius == BorderRadius.zero) {
70 paintBorder(canvas, rect,
71 top: top, right: right, bottom: bottom, left: left);
72 } else {
73 final RRect outer = borderRadius.toRRect(rect);
74 final RRect inner = outer.deflate(top.width);
75 final Paint paint = Paint()..color = top.color;
76 canvas.drawDRRect(outer, inner, paint);
77 }
78 }
79 }
80}
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。
また依頼した内容が修正された場合は、修正依頼を取り消すようにしましょう。
2022/11/27 07:05