@@ -3,6 +3,7 @@ import 'dart:math';
33
44import 'package:csslib/parser.dart' as cssparser;
55import 'package:csslib/visitor.dart' as css;
6+ import 'package:flutter/gestures.dart' ;
67import 'package:flutter/material.dart' ;
78import 'package:flutter_html/flutter_html.dart' ;
89import 'package:flutter_html/image_render.dart' ;
@@ -338,28 +339,48 @@ class HtmlParser extends StatelessWidget {
338339 );
339340 }
340341 } else if (tree is InteractableElement ) {
341- return WidgetSpan (
342- child: RawGestureDetector (
343- gestures: {
344- MultipleTapGestureRecognizer : GestureRecognizerFactoryWithHandlers <
345- MultipleTapGestureRecognizer >(
346- () => MultipleTapGestureRecognizer (),
347- (instance) {
348- instance..onTap = () => onLinkTap? .call (tree.href);
342+ InlineSpan addTaps (InlineSpan childSpan, TextStyle childStyle) {
343+ if (childSpan is TextSpan ) {
344+ return TextSpan (
345+ text: childSpan.text,
346+ children: childSpan.children
347+ ? .map ((e) => addTaps (e, childStyle.merge (childSpan.style)))
348+ ? .toList (),
349+ style: newContext.style.generateTextStyle ().merge (
350+ childSpan.style == null
351+ ? childStyle
352+ : childStyle.merge (childSpan.style)),
353+ semanticsLabel: childSpan.semanticsLabel,
354+ recognizer: TapGestureRecognizer ()
355+ ..onTap = () => onLinkTap? .call (tree.href),
356+ );
357+ } else {
358+ return WidgetSpan (
359+ child: RawGestureDetector (
360+ gestures: {
361+ MultipleTapGestureRecognizer :
362+ GestureRecognizerFactoryWithHandlers <
363+ MultipleTapGestureRecognizer >(
364+ () => MultipleTapGestureRecognizer (),
365+ (instance) {
366+ instance..onTap = () => onLinkTap? .call (tree.href);
367+ },
368+ ),
349369 },
370+ child: (childSpan as WidgetSpan ).child,
350371 ),
351- },
352- child : StyledText (
353- textSpan : TextSpan (
354- style : newContext.style. generateTextStyle (),
355- children : tree.children
356- . map (( tree) => parseTree (newContext, tree))
357- . toList () ??
358- [],
359- ) ,
360- style : newContext.style,
361- ),
362- ) ,
372+ );
373+ }
374+ }
375+
376+ return TextSpan (
377+ children : tree.children
378+ . map ((tree) => parseTree (newContext, tree))
379+ . map ((childSpan) {
380+ return addTaps (childSpan ,
381+ newContext.style. generateTextStyle (). merge (childSpan.style));
382+ }). toList () ??
383+ [] ,
363384 );
364385 } else if (tree is LayoutElement ) {
365386 return WidgetSpan (
@@ -652,6 +673,8 @@ class HtmlParser extends StatelessWidget {
652673 child.text.trim ().isEmpty &&
653674 lastChildBlock) {
654675 toRemove.add (child);
676+ } else if (child.style.display == Display .NONE ) {
677+ toRemove.add (child);
655678 } else {
656679 _removeEmptyElements (child);
657680 }
0 commit comments