Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions lib/html_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:csslib/parser.dart' as cssparser;
import 'package:csslib/visitor.dart' as css;
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:flutter_html/image_render.dart';
import 'package:flutter_html/src/anchor.dart';
Expand Down Expand Up @@ -410,6 +411,7 @@ class HtmlParser extends StatelessWidget {
InlineSpan addTaps(InlineSpan childSpan, TextStyle childStyle) {
if (childSpan is TextSpan) {
return TextSpan(
mouseCursor: SystemMouseCursors.click,
text: childSpan.text,
children: childSpan.children
?.map((e) => addTaps(e, childStyle.merge(childSpan.style)))
Expand All @@ -425,29 +427,34 @@ class HtmlParser extends StatelessWidget {
);
} else {
return WidgetSpan(
child: MultipleTapGestureDetector(
onTap: _onAnchorTap != null
? () => _onAnchorTap!(tree.href, context, tree.attributes, tree.element)
: null,
child: GestureDetector(
key: AnchorKey.of(key, tree),
child: MouseRegion(
key: AnchorKey.of(key, tree),
cursor: SystemMouseCursors.click,
child: MultipleTapGestureDetector(
onTap: _onAnchorTap != null
? () => _onAnchorTap!(tree.href, context, tree.attributes, tree.element)
? () => _onAnchorTap!(tree.href, context, tree.attributes, tree.element)
: null,
child: (childSpan as WidgetSpan).child,
child: GestureDetector(
key: AnchorKey.of(key, tree),
onTap: _onAnchorTap != null
? () => _onAnchorTap!(tree.href, context, tree.attributes, tree.element)
: null,
child: (childSpan as WidgetSpan).child,
),
),
),
);
}
}

return TextSpan(
mouseCursor: SystemMouseCursors.click,
children: tree.children
.map((tree) => parseTree(newContext, tree))
.map((childSpan) {
return addTaps(childSpan,
newContext.style.generateTextStyle().merge(childSpan.style));
}).toList(),
return addTaps(childSpan,
newContext.style.generateTextStyle().merge(childSpan.style));
}).toList(),
);
} else if (tree is LayoutElement) {
return WidgetSpan(
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ homepage: https://github.com/Sub6Resources/flutter_html

environment:
sdk: '>=2.12.0 <3.0.0'
flutter: '>=1.17.0'
flutter: '>=2.2.0'

dependencies:
# Plugin for parsing html
Expand Down