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 {
6565 GlobalKey ? anchorKey,
6666 required this .data,
6767 this .onLinkTap,
68+ this .onAnchorTap,
6869 this .customRender = const {},
6970 this .customImageRenders = const {},
7071 this .onCssParseError,
@@ -85,6 +86,7 @@ class Html extends StatelessWidget {
8586 GlobalKey ? anchorKey,
8687 @required this .document,
8788 this .onLinkTap,
89+ this .onAnchorTap,
8890 this .customRender = const {},
8991 this .customImageRenders = const {},
9092 this .onCssParseError,
@@ -112,6 +114,10 @@ class Html extends StatelessWidget {
112114 /// A function that defines what to do when a link is tapped
113115 final OnTap ? onLinkTap;
114116
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+
115121 /// An API that allows you to customize the entire process of image rendering.
116122 /// See the README for more details.
117123 final Map <ImageSourceMatcher , ImageRender > customImageRenders;
@@ -167,6 +173,7 @@ class Html extends StatelessWidget {
167173 key: _anchorKey,
168174 htmlData: doc,
169175 onLinkTap: onLinkTap,
176+ onAnchorTap: onAnchorTap,
170177 onImageTap: onImageTap,
171178 onCssParseError: onCssParseError,
172179 onImageError: onImageError,
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ class HtmlParser extends StatelessWidget {
4141 final Key ? key;
4242 final dom.Document htmlData;
4343 final OnTap ? onLinkTap;
44+ final OnTap ? onAnchorTap;
4445 final OnTap ? onImageTap;
4546 final OnCssParseError ? onCssParseError;
4647 final ImageErrorListener ? onImageError;
@@ -58,6 +59,7 @@ class HtmlParser extends StatelessWidget {
5859 required this .key,
5960 required this .htmlData,
6061 required this .onLinkTap,
62+ required this .onAnchorTap,
6163 required this .onImageTap,
6264 required this .onCssParseError,
6365 required this .onImageError,
@@ -68,7 +70,12 @@ class HtmlParser extends StatelessWidget {
6870 required this .imageRenders,
6971 required this .tagsList,
7072 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);
7279
7380 @override
7481 Widget build (BuildContext context) {
You can’t perform that action at this time.
0 commit comments