Skip to content

Commit 1d5fdba

Browse files
committed
Handle anchor taps also when no onLinkTap function is attached
1 parent ea949e8 commit 1d5fdba

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/html_parser.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class HtmlParser extends StatelessWidget {
6262
required this.imageRenders,
6363
required this.blacklistedElements,
6464
required this.navigationDelegateForIframe,
65-
}): this._onAnchorTap = key != null && onLinkTap != null ? _handleAnchorTap(key, onLinkTap): null, super(key: key);
65+
}): this._onAnchorTap = key != null ? _handleAnchorTap(key, onLinkTap): null, super(key: key);
6666

6767
@override
6868
Widget build(BuildContext context) {
@@ -442,7 +442,7 @@ class HtmlParser extends StatelessWidget {
442442
}
443443
}
444444

445-
static OnTap _handleAnchorTap(Key key, OnTap onLinkTap) =>
445+
static OnTap _handleAnchorTap(Key key, OnTap? onLinkTap) =>
446446
(String? url, RenderContext context, Map<String, String> attributes, dom.Element? element) {
447447
if (url?.startsWith("#") == true) {
448448
final anchorContext = AnchorKey.forId(key, url!.substring(1))?.currentContext;
@@ -451,7 +451,7 @@ class HtmlParser extends StatelessWidget {
451451
}
452452
return;
453453
}
454-
onLinkTap.call(url, context, attributes, element);
454+
onLinkTap?.call(url, context, attributes, element);
455455
};
456456

457457
/// [processWhitespace] removes unnecessary whitespace from the StyledElement tree.

0 commit comments

Comments
 (0)