File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,7 @@ class Html extends StatelessWidget {
65
65
GlobalKey ? anchorKey,
66
66
required this .data,
67
67
this .onLinkTap,
68
+ this .onAnchorTap,
68
69
this .customRender = const {},
69
70
this .customImageRenders = const {},
70
71
this .onCssParseError,
@@ -85,6 +86,7 @@ class Html extends StatelessWidget {
85
86
GlobalKey ? anchorKey,
86
87
@required this .document,
87
88
this .onLinkTap,
89
+ this .onAnchorTap,
88
90
this .customRender = const {},
89
91
this .customImageRenders = const {},
90
92
this .onCssParseError,
@@ -112,6 +114,10 @@ class Html extends StatelessWidget {
112
114
/// A function that defines what to do when a link is tapped
113
115
final OnTap ? onLinkTap;
114
116
117
+ /// A function that defines what to do when an anchor link is tapped. When this value is set,
118
+ /// the default anchor behaviour is overwritten.
119
+ final OnTap ? onAnchorTap;
120
+
115
121
/// An API that allows you to customize the entire process of image rendering.
116
122
/// See the README for more details.
117
123
final Map <ImageSourceMatcher , ImageRender > customImageRenders;
@@ -167,6 +173,7 @@ class Html extends StatelessWidget {
167
173
key: _anchorKey,
168
174
htmlData: doc,
169
175
onLinkTap: onLinkTap,
176
+ onAnchorTap: onAnchorTap,
170
177
onImageTap: onImageTap,
171
178
onCssParseError: onCssParseError,
172
179
onImageError: onImageError,
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ class HtmlParser extends StatelessWidget {
41
41
final Key ? key;
42
42
final dom.Document htmlData;
43
43
final OnTap ? onLinkTap;
44
+ final OnTap ? onAnchorTap;
44
45
final OnTap ? onImageTap;
45
46
final OnCssParseError ? onCssParseError;
46
47
final ImageErrorListener ? onImageError;
@@ -58,6 +59,7 @@ class HtmlParser extends StatelessWidget {
58
59
required this .key,
59
60
required this .htmlData,
60
61
required this .onLinkTap,
62
+ required this .onAnchorTap,
61
63
required this .onImageTap,
62
64
required this .onCssParseError,
63
65
required this .onImageError,
@@ -68,7 +70,12 @@ class HtmlParser extends StatelessWidget {
68
70
required this .imageRenders,
69
71
required this .tagsList,
70
72
required this .navigationDelegateForIframe,
71
- }): this ._onAnchorTap = key != null ? _handleAnchorTap (key, onLinkTap): null , super (key: key);
73
+ }) : this ._onAnchorTap = onAnchorTap != null
74
+ ? onAnchorTap
75
+ : key != null
76
+ ? _handleAnchorTap (key, onLinkTap)
77
+ : null ,
78
+ super (key: key);
72
79
73
80
@override
74
81
Widget build (BuildContext context) {
You can’t perform that action at this time.
0 commit comments