@@ -18,7 +18,12 @@ abstract class LayoutElement extends StyledElement {
1818 required List <StyledElement > children,
1919 String ? elementId,
2020 dom.Element ? node,
21- }) : super (name: name, children: children, style: Style (), node: node, elementId: elementId ?? "[[No ID]]" );
21+ }) : super (
22+ name: name,
23+ children: children,
24+ style: Style (),
25+ node: node,
26+ elementId: elementId ?? "[[No ID]]" );
2227
2328 Widget ? toWidget (RenderContext context);
2429}
@@ -34,16 +39,16 @@ class TableLayoutElement extends LayoutElement {
3439 Widget toWidget (RenderContext context) {
3540 return Container (
3641 key: AnchorKey .of (context.parser.key, this ),
42+ margin: style.margin? .asInsets.nonNegative ?? EdgeInsets .zero,
3743 padding: style.padding? .nonNegative,
38- margin: style.margin? .nonNegative,
39- alignment: style.alignment,
4044 decoration: BoxDecoration (
4145 color: style.backgroundColor,
4246 border: style.border,
4347 ),
4448 width: style.width,
4549 height: style.height,
46- child: LayoutBuilder (builder: (_, constraints) => _layoutCells (context, constraints)),
50+ child: LayoutBuilder (
51+ builder: (_, constraints) => _layoutCells (context, constraints)),
4752 );
4853 }
4954
@@ -89,18 +94,23 @@ class TableLayoutElement extends LayoutElement {
8994 }
9095
9196 // All table rows have a height intrinsic to their (spanned) contents
92- final rowSizes = List .generate (rows.length, (_) => IntrinsicContentTrackSize ());
97+ final rowSizes =
98+ List .generate (rows.length, (_) => IntrinsicContentTrackSize ());
9399
94100 // Calculate column bounds
95101 int columnMax = 0 ;
96102 List <int > rowSpanOffsets = [];
97103 for (final row in rows) {
98- final cols = row.children.whereType <TableCellElement >().fold (0 , (int value, child) => value + child.colspan) +
104+ final cols = row.children
105+ .whereType <TableCellElement >()
106+ .fold (0 , (int value, child) => value + child.colspan) +
99107 rowSpanOffsets.fold <int >(0 , (int offset, child) => child);
100108 columnMax = max (cols, columnMax);
101109 rowSpanOffsets = [
102110 ...rowSpanOffsets.map ((value) => value - 1 ).where ((value) => value > 0 ),
103- ...row.children.whereType <TableCellElement >().map ((cell) => cell.rowspan - 1 ),
111+ ...row.children
112+ .whereType <TableCellElement >()
113+ .map ((cell) => cell.rowspan - 1 ),
104114 ];
105115 }
106116
@@ -112,19 +122,21 @@ class TableLayoutElement extends LayoutElement {
112122 for (var row in rows) {
113123 int columni = 0 ;
114124 for (var child in row.children) {
115- if (columni > columnMax - 1 ) {
125+ if (columni > columnMax - 1 ) {
116126 break ;
117127 }
118128 if (child is TableCellElement ) {
119129 while (columnRowOffset[columni] > 0 ) {
120130 columnRowOffset[columni] = columnRowOffset[columni] - 1 ;
121- columni += columnColspanOffset[columni].clamp (1 , columnMax - columni - 1 );
131+ columni +=
132+ columnColspanOffset[columni].clamp (1 , columnMax - columni - 1 );
122133 }
123134 cells.add (GridPlacement (
124135 child: Container (
125136 width: child.style.width ?? double .infinity,
126137 height: child.style.height,
127- padding: child.style.padding? .nonNegative ?? row.style.padding? .nonNegative,
138+ padding: child.style.padding? .nonNegative ??
139+ row.style.padding? .nonNegative,
128140 decoration: BoxDecoration (
129141 color: child.style.backgroundColor ?? row.style.backgroundColor,
130142 border: child.style.border ?? row.style.border,
@@ -217,7 +229,13 @@ class TableCellElement extends StyledElement {
217229 required List <StyledElement > children,
218230 required Style style,
219231 required dom.Element node,
220- }) : super (name: name, elementId: elementId, elementClasses: elementClasses, children: children, style: style, node: node) {
232+ }) : super (
233+ name: name,
234+ elementId: elementId,
235+ elementClasses: elementClasses,
236+ children: children,
237+ style: style,
238+ node: node) {
221239 colspan = _parseSpan (this , "colspan" );
222240 rowspan = _parseSpan (this , "rowspan" );
223241 }
@@ -292,42 +310,55 @@ class DetailsContentElement extends LayoutElement {
292310
293311 @override
294312 Widget toWidget (RenderContext context) {
295- List <InlineSpan >? childrenList = children.map ((tree) => context.parser.parseTree (context, tree)).toList ();
313+ List <InlineSpan >? childrenList = children
314+ .map ((tree) => context.parser.parseTree (context, tree))
315+ .toList ();
296316 List <InlineSpan > toRemove = [];
297317 for (InlineSpan child in childrenList) {
298- if (child is TextSpan && child.text != null && child.text! .trim ().isEmpty) {
318+ if (child is TextSpan &&
319+ child.text != null &&
320+ child.text! .trim ().isEmpty) {
299321 toRemove.add (child);
300322 }
301323 }
302324 for (InlineSpan child in toRemove) {
303325 childrenList.remove (child);
304326 }
305- InlineSpan ? firstChild = childrenList.isNotEmpty == true ? childrenList.first : null ;
327+ InlineSpan ? firstChild =
328+ childrenList.isNotEmpty == true ? childrenList.first : null ;
306329 return ExpansionTile (
307330 key: AnchorKey .of (context.parser.key, this ),
308331 expandedAlignment: Alignment .centerLeft,
309- title: elementList.isNotEmpty == true && elementList.first.localName == "summary" ? StyledText (
310- textSpan: TextSpan (
311- style: style.generateTextStyle (),
312- children: firstChild == null ? [] : [firstChild],
313- ),
314- style: style,
315- renderContext: context,
316- ) : Text ("Details" ),
332+ title: elementList.isNotEmpty == true &&
333+ elementList.first.localName == "summary"
334+ ? StyledText (
335+ textSpan: TextSpan (
336+ style: style.generateTextStyle (),
337+ children: firstChild == null ? [] : [firstChild],
338+ ),
339+ style: style,
340+ renderContext: context,
341+ )
342+ : Text ("Details" ),
317343 children: [
318344 StyledText (
319345 textSpan: TextSpan (
320- style: style.generateTextStyle (),
321- children: getChildren (childrenList, context, elementList.isNotEmpty == true && elementList.first.localName == "summary" ? firstChild : null )
322- ),
346+ style: style.generateTextStyle (),
347+ children: getChildren (
348+ childrenList,
349+ context,
350+ elementList.isNotEmpty == true &&
351+ elementList.first.localName == "summary"
352+ ? firstChild
353+ : null )),
323354 style: style,
324355 renderContext: context,
325356 ),
326- ]
327- );
357+ ]);
328358 }
329359
330- List <InlineSpan > getChildren (List <InlineSpan > children, RenderContext context, InlineSpan ? firstChild) {
360+ List <InlineSpan > getChildren (List <InlineSpan > children, RenderContext context,
361+ InlineSpan ? firstChild) {
331362 if (firstChild != null ) children.removeAt (0 );
332363 return children;
333364 }
@@ -341,8 +372,8 @@ class EmptyLayoutElement extends LayoutElement {
341372}
342373
343374LayoutElement parseLayoutElement (
344- dom.Element element,
345- List <StyledElement > children,
375+ dom.Element element,
376+ List <StyledElement > children,
346377) {
347378 switch (element.localName) {
348379 case "details" :
@@ -353,8 +384,7 @@ LayoutElement parseLayoutElement(
353384 node: element,
354385 name: element.localName! ,
355386 children: children,
356- elementList: element.children
357- );
387+ elementList: element.children);
358388 case "table" :
359389 return TableLayoutElement (
360390 name: element.localName! ,
@@ -376,9 +406,6 @@ LayoutElement parseLayoutElement(
376406 );
377407 default :
378408 return TableLayoutElement (
379- children: children,
380- name: "[[No Name]]" ,
381- node: element
382- );
409+ children: children, name: "[[No Name]]" , node: element);
383410 }
384411}
0 commit comments