@@ -308,6 +308,13 @@ class RenderTableViewport extends RenderTwoDimensionalViewport {
308
308
);
309
309
}
310
310
311
+ // TODO(Piinks): Pinned rows/cols do not account for what is visible on the
312
+ // screen. Ostensibly, we would not want to have pinned rows/columns that
313
+ // extend beyond the viewport, we would never see them as they would never
314
+ // scroll into view. So this currently implementation is fairly assuming
315
+ // we will never have rows/cols that are outside of the viewport. We should
316
+ // maybe add an assertion for this during layout.
317
+ // https://github.com/flutter/flutter/issues/136833
311
318
int ? get _lastPinnedRow =>
312
319
delegate.pinnedRowCount > 0 ? delegate.pinnedRowCount - 1 : null ;
313
320
int ? get _lastPinnedColumn =>
@@ -667,12 +674,17 @@ class RenderTableViewport extends RenderTwoDimensionalViewport {
667
674
}) {
668
675
// TODO(Piinks): Assert here or somewhere else merged cells cannot span
669
676
// pinned and unpinned cells (for merged cell follow-up), https://github.com/flutter/flutter/issues/131224
677
+ _Span colSpan, rowSpan;
670
678
double yPaintOffset = - offset.dy;
671
679
for (int row = start.row; row <= end.row; row += 1 ) {
672
680
double xPaintOffset = - offset.dx;
673
- final double rowHeight = _rowMetrics[row]! .extent;
681
+ rowSpan = _rowMetrics[row]! ;
682
+ final double rowHeight = rowSpan.extent;
683
+ yPaintOffset += rowSpan.configuration.padding.leading;
674
684
for (int column = start.column; column <= end.column; column += 1 ) {
675
- final double columnWidth = _columnMetrics[column]! .extent;
685
+ colSpan = _columnMetrics[column]! ;
686
+ final double columnWidth = colSpan.extent;
687
+ xPaintOffset += colSpan.configuration.padding.leading;
676
688
677
689
final TableVicinity vicinity = TableVicinity (column: column, row: row);
678
690
// TODO(Piinks): Add back merged cells, https://github.com/flutter/flutter/issues/131224
@@ -689,9 +701,11 @@ class RenderTableViewport extends RenderTwoDimensionalViewport {
689
701
cell.layout (cellConstraints);
690
702
cellParentData.layoutOffset = Offset (xPaintOffset, yPaintOffset);
691
703
}
692
- xPaintOffset += columnWidth;
704
+ xPaintOffset += columnWidth +
705
+ _columnMetrics[column]! .configuration.padding.trailing;
693
706
}
694
- yPaintOffset += rowHeight;
707
+ yPaintOffset +=
708
+ rowHeight + _rowMetrics[row]! .configuration.padding.trailing;
695
709
}
696
710
}
697
711
@@ -836,29 +850,45 @@ class RenderTableViewport extends RenderTwoDimensionalViewport {
836
850
final LinkedHashMap <Rect , TableSpanDecoration > backgroundColumns =
837
851
LinkedHashMap <Rect , TableSpanDecoration >();
838
852
853
+ final TableSpan rowSpan = _rowMetrics[leading.row]! .configuration;
839
854
for (int column = leading.column; column <= trailing.column; column++ ) {
840
- final _Span span = _columnMetrics[column]! ;
841
- if (span.configuration .backgroundDecoration != null ||
842
- span.configuration .foregroundDecoration != null ) {
855
+ final TableSpan columnSpan = _columnMetrics[column]! .configuration ;
856
+ if (columnSpan .backgroundDecoration != null ||
857
+ columnSpan .foregroundDecoration != null ) {
843
858
final RenderBox leadingCell = getChildFor (
844
859
TableVicinity (column: column, row: leading.row),
845
860
)! ;
846
861
final RenderBox trailingCell = getChildFor (
847
862
TableVicinity (column: column, row: trailing.row),
848
863
)! ;
849
864
850
- final Rect rect = Rect .fromPoints (
851
- parentDataOf (leadingCell).paintOffset! + offset,
852
- parentDataOf (trailingCell).paintOffset! +
853
- Offset (trailingCell.size.width, trailingCell.size.height) +
854
- offset,
855
- );
865
+ Rect getColumnRect (bool consumePadding) {
866
+ return Rect .fromPoints (
867
+ parentDataOf (leadingCell).paintOffset! +
868
+ offset -
869
+ Offset (
870
+ consumePadding ? columnSpan.padding.leading : 0.0 ,
871
+ rowSpan.padding.leading,
872
+ ),
873
+ parentDataOf (trailingCell).paintOffset! +
874
+ offset +
875
+ Offset (trailingCell.size.width, trailingCell.size.height) +
876
+ Offset (
877
+ consumePadding ? columnSpan.padding.trailing : 0.0 ,
878
+ rowSpan.padding.trailing,
879
+ ),
880
+ );
881
+ }
856
882
857
- if (span.configuration.backgroundDecoration != null ) {
858
- backgroundColumns[rect] = span.configuration.backgroundDecoration! ;
883
+ if (columnSpan.backgroundDecoration != null ) {
884
+ final Rect rect = getColumnRect (
885
+ columnSpan.backgroundDecoration! .consumeSpanPadding);
886
+ backgroundColumns[rect] = columnSpan.backgroundDecoration! ;
859
887
}
860
- if (span.configuration.foregroundDecoration != null ) {
861
- foregroundColumns[rect] = span.configuration.foregroundDecoration! ;
888
+ if (columnSpan.foregroundDecoration != null ) {
889
+ final Rect rect = getColumnRect (
890
+ columnSpan.foregroundDecoration! .consumeSpanPadding);
891
+ foregroundColumns[rect] = columnSpan.foregroundDecoration! ;
862
892
}
863
893
}
864
894
}
@@ -869,28 +899,45 @@ class RenderTableViewport extends RenderTwoDimensionalViewport {
869
899
final LinkedHashMap <Rect , TableSpanDecoration > backgroundRows =
870
900
LinkedHashMap <Rect , TableSpanDecoration >();
871
901
902
+ final TableSpan columnSpan = _columnMetrics[leading.column]! .configuration;
872
903
for (int row = leading.row; row <= trailing.row; row++ ) {
873
- final _Span span = _rowMetrics[row]! ;
874
- if (span.configuration .backgroundDecoration != null ||
875
- span.configuration .foregroundDecoration != null ) {
904
+ final TableSpan rowSpan = _rowMetrics[row]! .configuration ;
905
+ if (rowSpan .backgroundDecoration != null ||
906
+ rowSpan .foregroundDecoration != null ) {
876
907
final RenderBox leadingCell = getChildFor (
877
908
TableVicinity (column: leading.column, row: row),
878
909
)! ;
879
910
final RenderBox trailingCell = getChildFor (
880
911
TableVicinity (column: trailing.column, row: row),
881
912
)! ;
882
913
883
- final Rect rect = Rect .fromPoints (
884
- parentDataOf (leadingCell).paintOffset! + offset,
885
- parentDataOf (trailingCell).paintOffset! +
886
- Offset (trailingCell.size.width, trailingCell.size.height) +
887
- offset,
888
- );
889
- if (span.configuration.backgroundDecoration != null ) {
890
- backgroundRows[rect] = span.configuration.backgroundDecoration! ;
914
+ Rect getRowRect (bool consumePadding) {
915
+ return Rect .fromPoints (
916
+ parentDataOf (leadingCell).paintOffset! +
917
+ offset -
918
+ Offset (
919
+ columnSpan.padding.leading,
920
+ consumePadding ? rowSpan.padding.leading : 0.0 ,
921
+ ),
922
+ parentDataOf (trailingCell).paintOffset! +
923
+ offset +
924
+ Offset (trailingCell.size.width, trailingCell.size.height) +
925
+ Offset (
926
+ columnSpan.padding.leading,
927
+ consumePadding ? rowSpan.padding.trailing : 0.0 ,
928
+ ),
929
+ );
930
+ }
931
+
932
+ if (rowSpan.backgroundDecoration != null ) {
933
+ final Rect rect =
934
+ getRowRect (rowSpan.backgroundDecoration! .consumeSpanPadding);
935
+ backgroundRows[rect] = rowSpan.backgroundDecoration! ;
891
936
}
892
- if (span.configuration.foregroundDecoration != null ) {
893
- foregroundRows[rect] = span.configuration.foregroundDecoration! ;
937
+ if (rowSpan.foregroundDecoration != null ) {
938
+ final Rect rect =
939
+ getRowRect (rowSpan.foregroundDecoration! .consumeSpanPadding);
940
+ foregroundRows[rect] = rowSpan.foregroundDecoration! ;
894
941
}
895
942
}
896
943
}
@@ -1028,7 +1075,12 @@ class _Span
1028
1075
bool get isPinned => _isPinned;
1029
1076
late bool _isPinned;
1030
1077
1031
- double get trailingOffset => leadingOffset + extent;
1078
+ double get trailingOffset {
1079
+ return leadingOffset +
1080
+ extent +
1081
+ configuration.padding.leading +
1082
+ configuration.padding.trailing;
1083
+ }
1032
1084
1033
1085
// ---- Span Management ----
1034
1086
0 commit comments