@@ -78,15 +78,19 @@ class HtmlParser extends StatelessWidget {
7878
7979 /// [lexDomTree] converts a DOM document to a simplified tree of [StyledElement] s.
8080 static StyledElement lexDomTree (
81- dom.Document html, List <String > customRenderTags, List <String > blacklistedElements) {
81+ dom.Document html,
82+ List <String > customRenderTags,
83+ List <String > blacklistedElements,
84+ ) {
8285 StyledElement tree = StyledElement (
8386 name: "[Tree Root]" ,
8487 children: new List <StyledElement >(),
8588 node: html.documentElement,
8689 );
8790
8891 html.nodes.forEach ((node) {
89- tree.children.add (_recursiveLexer (node, customRenderTags, blacklistedElements));
92+ tree.children
93+ .add (_recursiveLexer (node, customRenderTags, blacklistedElements));
9094 });
9195
9296 return tree;
@@ -97,11 +101,15 @@ class HtmlParser extends StatelessWidget {
97101 /// It runs the parse functions of every type of
98102 /// element and returns a [StyledElement] tree representing the element.
99103 static StyledElement _recursiveLexer (
100- dom.Node node, List <String > customRenderTags, List <String > blacklistedElements) {
104+ dom.Node node,
105+ List <String > customRenderTags,
106+ List <String > blacklistedElements,
107+ ) {
101108 List <StyledElement > children = List <StyledElement >();
102109
103110 node.nodes.forEach ((childNode) {
104- children.add (_recursiveLexer (childNode, customRenderTags, blacklistedElements));
111+ children.add (
112+ _recursiveLexer (childNode, customRenderTags, blacklistedElements));
105113 });
106114
107115 //TODO(Sub6Resources): There's probably a more efficient way to look this up.
@@ -226,7 +234,10 @@ class HtmlParser extends StatelessWidget {
226234 newContext: newContext,
227235 style: tree.style,
228236 shrinkWrap: context.parser.shrinkWrap,
229- children: tree.children? .map ((tree) => parseTree (newContext, tree))? .toList () ?? [],
237+ children: tree.children
238+ ? .map ((tree) => parseTree (newContext, tree))
239+ ? .toList () ??
240+ [],
230241 ),
231242 tree.attributes,
232243 ),
@@ -241,7 +252,10 @@ class HtmlParser extends StatelessWidget {
241252 newContext: newContext,
242253 style: tree.style,
243254 shrinkWrap: context.parser.shrinkWrap,
244- children: tree.children? .map ((tree) => parseTree (newContext, tree))? .toList () ?? [],
255+ children: tree.children
256+ ? .map ((tree) => parseTree (newContext, tree))
257+ ? .toList () ??
258+ [],
245259 ),
246260 );
247261 } else if (tree.style? .display == Display .LIST_ITEM ) {
@@ -256,14 +270,18 @@ class HtmlParser extends StatelessWidget {
256270 width: 30 , //TODO derive this from list padding.
257271 start: 0 ,
258272 child: Text ('${newContext .style .markerContent }\t ' ,
259- textAlign: TextAlign .right, style: newContext.style.generateTextStyle ()),
273+ textAlign: TextAlign .right,
274+ style: newContext.style.generateTextStyle ()),
260275 ),
261276 Padding (
262- padding: EdgeInsets .only (left: 30 ), //TODO derive this from list padding.
277+ padding: EdgeInsets .only (
278+ left: 30 ), //TODO derive this from list padding.
263279 child: RichText (
264280 text: TextSpan (
265- children:
266- tree.children? .map ((tree) => parseTree (newContext, tree))? .toList () ?? [],
281+ children: tree.children
282+ ? .map ((tree) => parseTree (newContext, tree))
283+ ? .toList () ??
284+ [],
267285 style: newContext.style.generateTextStyle (),
268286 ),
269287 ),
@@ -286,17 +304,21 @@ class HtmlParser extends StatelessWidget {
286304 return WidgetSpan (
287305 child: RawGestureDetector (
288306 gestures: {
289- MultipleTapGestureRecognizer : GestureRecognizerFactoryWithHandlers <MultipleTapGestureRecognizer >(
290- () => MultipleTapGestureRecognizer (),
291- (instance) {
292- instance..onTap = () => onLinkTap? .call (tree.href);
293- },
307+ MultipleTapGestureRecognizer : GestureRecognizerFactoryWithHandlers <
308+ MultipleTapGestureRecognizer >(
309+ () => MultipleTapGestureRecognizer (),
310+ (instance) {
311+ instance..onTap = () => onLinkTap? .call (tree.href);
312+ },
294313 ),
295314 },
296315 child: RichText (
297316 text: TextSpan (
298317 style: newContext.style.generateTextStyle (),
299- children: tree.children.map ((tree) => parseTree (newContext, tree)).toList () ?? [],
318+ children: tree.children
319+ .map ((tree) => parseTree (newContext, tree))
320+ .toList () ??
321+ [],
300322 ),
301323 ),
302324 ),
@@ -325,7 +347,10 @@ class HtmlParser extends StatelessWidget {
325347 child: RichText (
326348 text: TextSpan (
327349 style: newContext.style.generateTextStyle (),
328- children: tree.children.map ((tree) => parseTree (newContext, tree)).toList () ?? [],
350+ children: tree.children
351+ .map ((tree) => parseTree (newContext, tree))
352+ .toList () ??
353+ [],
329354 ),
330355 ),
331356 ),
@@ -334,7 +359,8 @@ class HtmlParser extends StatelessWidget {
334359 ///[tree] is an inline element.
335360 return TextSpan (
336361 style: newContext.style.generateTextStyle (),
337- children: tree.children.map ((tree) => parseTree (newContext, tree)).toList (),
362+ children:
363+ tree.children.map ((tree) => parseTree (newContext, tree)).toList (),
338364 );
339365 }
340366 }
@@ -367,7 +393,10 @@ class HtmlParser extends StatelessWidget {
367393 /// [_processInlineWhitespaceRecursive] analyzes the whitespace between and among different
368394 /// inline elements, and replaces any instance of two or more spaces with a single space, according
369395 /// to the w3's HTML whitespace processing specification linked to above.
370- static StyledElement _processInlineWhitespaceRecursive (StyledElement tree, Context <bool > wpc) {
396+ static StyledElement _processInlineWhitespaceRecursive (
397+ StyledElement tree,
398+ Context <bool > wpc,
399+ ) {
371400 if (tree.style.display == Display .BLOCK ) {
372401 wpc.data = false ;
373402 }
@@ -500,7 +529,8 @@ class HtmlParser extends StatelessWidget {
500529 if (tree.children.first.style.margin == null ) {
501530 tree.children.first.style.margin = EdgeInsets .zero;
502531 } else {
503- tree.children.first.style.margin = tree.children.first.style.margin.copyWith (top: 0 );
532+ tree.children.first.style.margin =
533+ tree.children.first.style.margin.copyWith (top: 0 );
504534 }
505535 }
506536
@@ -515,33 +545,38 @@ class HtmlParser extends StatelessWidget {
515545 if (tree.style.margin == null ) {
516546 tree.style.margin = EdgeInsets .only (bottom: newOuterMarginBottom);
517547 } else {
518- tree.style.margin = tree.style.margin.copyWith (bottom: newOuterMarginBottom);
548+ tree.style.margin =
549+ tree.style.margin.copyWith (bottom: newOuterMarginBottom);
519550 }
520551
521552 // And remove the child's margin
522553 if (tree.children.last.style.margin == null ) {
523554 tree.children.last.style.margin = EdgeInsets .zero;
524555 } else {
525- tree.children.last.style.margin = tree.children.last.style.margin.copyWith (bottom: 0 );
556+ tree.children.last.style.margin =
557+ tree.children.last.style.margin.copyWith (bottom: 0 );
526558 }
527559 }
528560
529561 // Handle case (2) from above.
530562 if (tree.children.length > 1 ) {
531563 for (int i = 1 ; i < tree.children.length; i++ ) {
532- final previousSiblingBottom = tree.children[i - 1 ].style.margin? .bottom ?? 0 ;
564+ final previousSiblingBottom =
565+ tree.children[i - 1 ].style.margin? .bottom ?? 0 ;
533566 final thisTop = tree.children[i].style.margin? .top ?? 0 ;
534567 final newInternalMargin = max (previousSiblingBottom, thisTop) / 2 ;
535568
536569 if (tree.children[i - 1 ].style.margin == null ) {
537- tree.children[i - 1 ].style.margin = EdgeInsets .only (bottom: newInternalMargin);
538- } else {
539570 tree.children[i - 1 ].style.margin =
540- tree.children[i - 1 ].style.margin.copyWith (bottom: newInternalMargin);
571+ EdgeInsets .only (bottom: newInternalMargin);
572+ } else {
573+ tree.children[i - 1 ].style.margin = tree.children[i - 1 ].style.margin
574+ .copyWith (bottom: newInternalMargin);
541575 }
542576
543577 if (tree.children[i].style.margin == null ) {
544- tree.children[i].style.margin = EdgeInsets .only (top: newInternalMargin);
578+ tree.children[i].style.margin =
579+ EdgeInsets .only (top: newInternalMargin);
545580 } else {
546581 tree.children[i].style.margin =
547582 tree.children[i].style.margin.copyWith (top: newInternalMargin);
@@ -584,7 +619,8 @@ class HtmlParser extends StatelessWidget {
584619
585620 tree.children? .forEach ((child) {
586621 if ((child.style.fontSize? .size ?? parentFontSize) < 0 ) {
587- child.style.fontSize = FontSize (parentFontSize * - child.style.fontSize.size);
622+ child.style.fontSize =
623+ FontSize (parentFontSize * - child.style.fontSize.size);
588624 }
589625
590626 _processFontSize (child);
@@ -639,7 +675,7 @@ class ContainerSpan extends StatelessWidget {
639675 width: style? .width,
640676 padding: style? .padding,
641677 margin: style? .margin,
642- alignment: shrinkWrap? null : style? .alignment,
678+ alignment: shrinkWrap ? null : style? .alignment,
643679 child: child ??
644680 RichText (
645681 text: TextSpan (
0 commit comments