@@ -3,6 +3,7 @@ import 'dart:math';
3
3
4
4
import 'package:csslib/parser.dart' as cssparser;
5
5
import 'package:csslib/visitor.dart' as css;
6
+ import 'package:flutter/gestures.dart' ;
6
7
import 'package:flutter/material.dart' ;
7
8
import 'package:flutter_html/flutter_html.dart' ;
8
9
import 'package:flutter_html/image_render.dart' ;
@@ -338,28 +339,48 @@ class HtmlParser extends StatelessWidget {
338
339
);
339
340
}
340
341
} 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
+ ),
349
369
},
370
+ child: (childSpan as WidgetSpan ).child,
350
371
),
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
+ [] ,
363
384
);
364
385
} else if (tree is LayoutElement ) {
365
386
return WidgetSpan (
@@ -652,6 +673,8 @@ class HtmlParser extends StatelessWidget {
652
673
child.text.trim ().isEmpty &&
653
674
lastChildBlock) {
654
675
toRemove.add (child);
676
+ } else if (child.style.display == Display .NONE ) {
677
+ toRemove.add (child);
655
678
} else {
656
679
_removeEmptyElements (child);
657
680
}
0 commit comments