Skip to content

Commit 446cb74

Browse files
author
Andrei
committed
Added parser for 'width' and 'height' attributes for img
1 parent af4ca1d commit 446cb74

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

lib/html_parser.dart

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -630,8 +630,14 @@ class HtmlRichTextParser extends StatelessWidget {
630630
parseContext.rootWidgetList.add(GestureDetector(
631631
child: Image.memory(
632632
base64.decode(node.attributes['src'].split("base64,")[1].trim()),
633-
width: imageProperties?.width,
634-
height: imageProperties?.height,
633+
width: imageProperties?.width ??
634+
((node.attributes['width'] != null)
635+
? double.parse(node.attributes['width'])
636+
: null),
637+
height: imageProperties?.height ??
638+
((node.attributes['height'] != null)
639+
? double.parse(node.attributes['height'])
640+
: null),
635641
scale: imageProperties?.scale ?? 1.0,
636642
matchTextDirection: imageProperties?.matchTextDirection ?? false,
637643
centerSlice: imageProperties?.centerSlice,
@@ -655,8 +661,14 @@ class HtmlRichTextParser extends StatelessWidget {
655661
parseContext.rootWidgetList.add(GestureDetector(
656662
child: Image.network(
657663
node.attributes['src'],
658-
width: imageProperties?.width,
659-
height: imageProperties?.height,
664+
width: imageProperties?.width ??
665+
((node.attributes['width'] != null)
666+
? double.parse(node.attributes['width'])
667+
: null),
668+
height: imageProperties?.height ??
669+
((node.attributes['height'] != null)
670+
? double.parse(node.attributes['height'])
671+
: null),
660672
scale: imageProperties?.scale ?? 1.0,
661673
matchTextDirection: imageProperties?.matchTextDirection ?? false,
662674
centerSlice: imageProperties?.centerSlice,

0 commit comments

Comments
 (0)