Skip to content

Commit d523e56

Browse files
authored
Merge pull request #716 from vrtdev/bugfix/685-colspan-rowspan-fixes
Fixes #687 with a rowspan issue
2 parents 25df803 + 71138ac commit d523e56

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lib/src/layout_element.dart

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,14 @@ class TableLayoutElement extends LayoutElement {
9999

100100
// Place the cells in the rows/columns
101101
final cells = <GridPlacement>[];
102-
final columnRowOffset = List.generate(columnMax + 1, (_) => 0);
102+
final columnRowOffset = List.generate(columnMax, (_) => 0);
103103
int rowi = 0;
104104
for (var row in rows) {
105105
int columni = 0;
106106
for (var child in row.children) {
107+
if (columni > columnMax - 1 ) {
108+
break;
109+
}
107110
while (columnRowOffset[columni] > 0) {
108111
columnRowOffset[columni] = columnRowOffset[columni] - 1;
109112
columni++;
@@ -131,14 +134,18 @@ class TableLayoutElement extends LayoutElement {
131134
),
132135
),
133136
columnStart: columni,
134-
columnSpan: child.colspan,
137+
columnSpan: min(child.colspan, columnMax - columni),
135138
rowStart: rowi,
136-
rowSpan: child.rowspan,
139+
rowSpan: min(child.rowspan, rows.length - rowi),
137140
));
138141
columnRowOffset[columni] = child.rowspan - 1;
139142
columni += child.colspan;
140143
}
141144
}
145+
while (columni < columnRowOffset.length) {
146+
columnRowOffset[columni] = columnRowOffset[columni] - 1;
147+
columni++;
148+
}
142149
rowi++;
143150
}
144151

0 commit comments

Comments
 (0)