diff --git a/packages/flutter_html_svg/lib/flutter_html_svg.dart b/packages/flutter_html_svg/lib/flutter_html_svg.dart index 0cf7383085..be208e636a 100644 --- a/packages/flutter_html_svg/lib/flutter_html_svg.dart +++ b/packages/flutter_html_svg/lib/flutter_html_svg.dart @@ -10,7 +10,6 @@ import 'package:flutter_svg/flutter_svg.dart'; // TODO re-add MultipleGestureDetector for image taps in this extension class SvgHtmlExtension extends Extension { - final String? dataEncoding; final String? dataMimeType; final List networkSchemas; @@ -34,11 +33,11 @@ class SvgHtmlExtension extends Extension { @override bool matches(ExtensionContext context) { - if(!supportedTags.contains(context.elementName)) { + if (!supportedTags.contains(context.elementName)) { return false; } - if(context.elementName == "svg") { + if (context.elementName == "svg") { return true; } @@ -51,7 +50,7 @@ class SvgHtmlExtension extends Extension { bool _matchesSvgDataUri(ExtensionContext context) { final attributes = context.attributes; - if(attributes['src'] == null) { + if (attributes['src'] == null) { return false; } @@ -60,20 +59,20 @@ class SvgHtmlExtension extends Extension { return context.elementName == "img" && dataUri != null && (dataMimeType == null || dataUri.namedGroup('mime') == dataMimeType) && - (dataEncoding == null || dataUri.namedGroup('encoding') == dataEncoding); + (dataEncoding == null || + dataUri.namedGroup('encoding') == dataEncoding); } /// Matches an tag with an svg network image bool _matchesSvgNetworkSource(ExtensionContext context) { final attributes = context.attributes; - if(attributes['src'] == null) { + if (attributes['src'] == null) { return false; } - final src = Uri.tryParse(attributes['src']!); - if(src == null) { + if (src == null) { return false; } @@ -81,7 +80,6 @@ class SvgHtmlExtension extends Extension { networkSchemas.contains(src.scheme) && (networkDomains == null || networkDomains!.contains(src.host)) && (extension == null || src.path.endsWith(".$extension")); - } /// Matches an tag with an svg asset image @@ -142,7 +140,7 @@ class SvgHtmlExtension extends Extension { widget = _renderAssetSvg(context); } else if (_matchesSvgDataUri(context)) { widget = _renderDataSvg(context); - } else if (_matchesSvgNetworkSource(context)){ + } else if (_matchesSvgNetworkSource(context)) { widget = _renderNetworkSvg(context); } } diff --git a/packages/flutter_html_svg/test/svg_data_image_test.dart b/packages/flutter_html_svg/test/svg_data_image_test.dart index ee4189eca3..c545935812 100644 --- a/packages/flutter_html_svg/test/svg_data_image_test.dart +++ b/packages/flutter_html_svg/test/svg_data_image_test.dart @@ -22,7 +22,7 @@ void main() { testMatchAndRender( "matches and renders image/svg+xml with text encoding", makeImgTag( - src: 'data:image/svg+xml,$svgEncoded', width: 100, height: 100), + src: 'data:image/svg+xml,$svgEncoded', width: 100, height: 100), const SvgHtmlExtension( dataEncoding: null, ),