Skip to content

Commit 8722e42

Browse files
author
Andrei
committed
onImageTap change to use String source param
1 parent 56ba649 commit 8722e42

File tree

1 file changed

+14
-21
lines changed

1 file changed

+14
-21
lines changed

lib/html_parser.dart

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ typedef CustomTextStyle = TextStyle Function(
1212
);
1313
typedef CustomEdgeInsets = EdgeInsets Function(dom.Node node);
1414
typedef OnLinkTap = void Function(String url);
15-
typedef OnImageTap = void Function();
15+
typedef OnImageTap = void Function(String source);
1616

1717
const OFFSET_TAGS_FONT_SIZE_FACTOR =
1818
0.7; //The ratio of the parent font for each of the offset tags: sup or sub
@@ -733,23 +733,20 @@ class HtmlRichTextParser extends StatelessWidget {
733733
? double.parse(node.attributes['height'])
734734
: null),
735735
scale: imageProperties?.scale ?? 1.0,
736-
matchTextDirection:
737-
imageProperties?.matchTextDirection ?? false,
736+
matchTextDirection: imageProperties?.matchTextDirection ?? false,
738737
centerSlice: imageProperties?.centerSlice,
739-
filterQuality:
740-
imageProperties?.filterQuality ?? FilterQuality.low,
738+
filterQuality: imageProperties?.filterQuality ?? FilterQuality.low,
741739
alignment: imageProperties?.alignment ?? Alignment.center,
742740
colorBlendMode: imageProperties?.colorBlendMode,
743741
fit: imageProperties?.fit,
744742
color: imageProperties?.color,
745743
repeat: imageProperties?.repeat ?? ImageRepeat.noRepeat,
746744
semanticLabel: imageProperties?.semanticLabel,
747-
excludeFromSemantics:
748-
(imageProperties?.semanticLabel == null)
749-
? true
750-
: false,
745+
excludeFromSemantics: (imageProperties?.semanticLabel == null) ? true : false,
751746
),
752-
onTap: onImageTap,
747+
onTap: () {
748+
onImageTap(node.attributes['src']);
749+
},
753750
));
754751
} else {
755752
precacheImage(
@@ -769,29 +766,25 @@ class HtmlRichTextParser extends StatelessWidget {
769766
? double.parse(node.attributes['height'])
770767
: null),
771768
scale: imageProperties?.scale ?? 1.0,
772-
matchTextDirection:
773-
imageProperties?.matchTextDirection ?? false,
769+
matchTextDirection: imageProperties?.matchTextDirection ?? false,
774770
centerSlice: imageProperties?.centerSlice,
775-
filterQuality:
776-
imageProperties?.filterQuality ?? FilterQuality.low,
771+
filterQuality: imageProperties?.filterQuality ?? FilterQuality.low,
777772
alignment: imageProperties?.alignment ?? Alignment.center,
778773
colorBlendMode: imageProperties?.colorBlendMode,
779774
fit: imageProperties?.fit,
780775
color: imageProperties?.color,
781776
repeat: imageProperties?.repeat ?? ImageRepeat.noRepeat,
782777
semanticLabel: imageProperties?.semanticLabel,
783-
excludeFromSemantics:
784-
(imageProperties?.semanticLabel == null)
785-
? true
786-
: false,
778+
excludeFromSemantics: (imageProperties?.semanticLabel == null) ? true : false,
787779
),
788-
onTap: onImageTap,
780+
onTap: () {
781+
onImageTap(node.attributes['src']);
782+
},
789783
));
790784
}
791785
if (node.attributes['alt'] != null) {
792786
parseContext.rootWidgetList.add(BlockText(
793-
margin:
794-
EdgeInsets.symmetric(horizontal: 0.0, vertical: 10.0),
787+
margin: EdgeInsets.symmetric(horizontal: 0.0, vertical: 10.0),
795788
padding: EdgeInsets.all(0.0),
796789
child: RichText(
797790
textAlign: TextAlign.center,

0 commit comments

Comments
 (0)