@@ -245,19 +245,19 @@ TableStyleElement parseTableDefinitionElement(dom.Element element,
245245}
246246
247247class DetailsContentElement extends LayoutElement {
248- List <dom.Element > title ;
248+ List <dom.Element > elementList ;
249249
250250 DetailsContentElement ({
251251 String name,
252252 List <StyledElement > children,
253253 dom.Element node,
254- this .title ,
254+ this .elementList ,
255255 }) : super (name: name, node: node, children: children);
256256
257257 @override
258258 Widget toWidget (RenderContext context) {
259259 return ExpansionTile (
260- title: title .first.localName == "summary" && children != null ? StyledText (
260+ title: children != null && elementList .first.localName == "summary" ? StyledText (
261261 textSpan: TextSpan (
262262 style: style.generateTextStyle (),
263263 children: [children
@@ -271,16 +271,30 @@ class DetailsContentElement extends LayoutElement {
271271 StyledText (
272272 textSpan: TextSpan (
273273 style: style.generateTextStyle (),
274- children: children
275- .map ((tree) => context.parser.parseTree (context, tree))
276- .toList () ??
277- [],
274+ children: getChildren (children, context)
278275 ),
279276 style: style,
280277 ),
281278 ]
282279 );
283280 }
281+
282+ List <InlineSpan > getChildren (List <StyledElement > children, RenderContext context) {
283+ if (children.map ((tree) => context.parser.parseTree (context, tree)).toList () == null ) {
284+ return [];
285+ } else {
286+ List <InlineSpan > reducedChildren = children.map ((tree) => context.parser.parseTree (context, tree)).toList ();
287+ reducedChildren.removeAt (0 );
288+ return reducedChildren;
289+ }
290+ }
291+ }
292+
293+ class EmptyLayoutElement extends LayoutElement {
294+ EmptyLayoutElement ({String name = "empty" }) : super (name: name);
295+
296+ @override
297+ Widget toWidget (_) => null ;
284298}
285299
286300LayoutElement parseLayoutElement (
@@ -289,13 +303,14 @@ LayoutElement parseLayoutElement(
289303) {
290304 switch (element.localName) {
291305 case "details" :
306+ if (children == null || children.isEmpty) {
307+ return EmptyLayoutElement ();
308+ }
292309 return DetailsContentElement (
293310 node: element,
294311 name: element.localName,
295- //todo
296- //need to remove the summary tag itself before passing the children to the widget build function somehow
297- children: element.children.first.localName == "summary" ? children : children,
298- title: element.children
312+ children: children,
313+ elementList: element.children
299314 );
300315 case "table" :
301316 return TableLayoutElement (
0 commit comments