@@ -3,6 +3,14 @@ import 'package:flutter_html/src/html_elements.dart';
3
3
import 'package:flutter_html/style.dart' ;
4
4
import 'package:html/dom.dart' as dom;
5
5
6
+ import 'html_elements.dart' ;
7
+ import 'html_elements.dart' ;
8
+ import 'html_elements.dart' ;
9
+ import 'html_elements.dart' ;
10
+ import 'html_elements.dart' ;
11
+ import 'html_elements.dart' ;
12
+ import 'html_elements.dart' ;
13
+
6
14
/// An [InteractableElement] is a [StyledElement] that takes user gestures (e.g. tap).
7
15
class InteractableElement extends StyledElement {
8
16
String href;
@@ -32,10 +40,38 @@ InteractableElement parseInteractableElement(
32
40
switch (element.localName) {
33
41
case "a" :
34
42
interactableElement.href = element.attributes['href' ];
35
- interactableElement.style = Style (
36
- color: Colors .blue,
37
- textDecoration: TextDecoration .underline,
38
- );
43
+ if (element.children? .isEmpty ?? true ) {
44
+ interactableElement.style = Style (
45
+ textDecoration: TextDecoration .underline,
46
+ color: Colors .blue,
47
+ );
48
+ } else {
49
+ final allWidgets = List <TextContentElement >();
50
+ List <StyledElement > searchQueue =
51
+ List .from (interactableElement.children);
52
+
53
+ // recursively
54
+ while (searchQueue.isNotEmpty) {
55
+ final List <StyledElement > nextSearch = searchQueue
56
+ .expand ((e) => e? .children ?? List <StyledElement >())
57
+ .toList ();
58
+ allWidgets.addAll (nextSearch
59
+ .where ((element) => element is TextContentElement )
60
+ .map ((e) => e as TextContentElement ));
61
+ searchQueue = nextSearch;
62
+ }
63
+
64
+ allWidgets
65
+ .where ((element) => element is TextContentElement )
66
+ .forEach ((element) {
67
+ final style = element.style ?? Style ();
68
+ element.style = style.copyWith (
69
+ textDecoration: TextDecoration .underline,
70
+ color: Colors .blue,
71
+ );
72
+ });
73
+ }
74
+
39
75
break ;
40
76
}
41
77
0 commit comments