@@ -787,6 +787,59 @@ class HtmlRichTextParser extends StatelessWidget {
787787 }
788788 },
789789 ));
790+ } else if (node.attributes['src' ].startsWith ('asset:' )) {
791+ final assetPath = node.attributes['src' ].replaceFirst ('asset:' , '' );
792+ precacheImage (
793+ AssetImage (assetPath),
794+ buildContext,
795+ onError: onImageError ?? (_, __) {},
796+ );
797+ parseContext.rootWidgetList.add (GestureDetector (
798+ child: Image .asset (
799+ assetPath,
800+ frameBuilder: (context, child, frame, _) {
801+ if (node.attributes['alt' ] != null && frame == null ) {
802+ return BlockText (
803+ child: RichText (
804+ textAlign: TextAlign .center,
805+ text: TextSpan (
806+ text: node.attributes['alt' ],
807+ style: nextContext.childStyle,
808+ ),
809+ ),
810+ shrinkToFit: shrinkToFit,
811+ );
812+ }
813+ if (frame != null ) {
814+ return child;
815+ }
816+ return Container ();
817+ },
818+ width: (width ?? - 1 ) > 0 ? width : null ,
819+ height: (height ?? - 1 ) > 0 ? height : null ,
820+ scale: imageProperties? .scale ?? 1.0 ,
821+ matchTextDirection:
822+ imageProperties? .matchTextDirection ?? false ,
823+ centerSlice: imageProperties? .centerSlice,
824+ filterQuality:
825+ imageProperties? .filterQuality ?? FilterQuality .low,
826+ alignment: imageProperties? .alignment ?? Alignment .center,
827+ colorBlendMode: imageProperties? .colorBlendMode,
828+ fit: imageProperties? .fit,
829+ color: imageProperties? .color,
830+ repeat: imageProperties? .repeat ?? ImageRepeat .noRepeat,
831+ semanticLabel: imageProperties? .semanticLabel,
832+ excludeFromSemantics:
833+ (imageProperties? .semanticLabel == null )
834+ ? true
835+ : false ,
836+ ),
837+ onTap: () {
838+ if (onImageTap != null ) {
839+ onImageTap (node.attributes['src' ]);
840+ }
841+ },
842+ ));
790843 } else {
791844 precacheImage (
792845 NetworkImage (node.attributes['src' ]),
0 commit comments