Skip to content

Commit

Permalink
Run flutter format once more
Browse files Browse the repository at this point in the history
  • Loading branch information
Sub6Resources committed May 9, 2023
1 parent fb16b8d commit 5ae5cc4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
18 changes: 8 additions & 10 deletions packages/flutter_html_svg/lib/flutter_html_svg.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> networkSchemas;
Expand All @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -60,28 +59,27 @@ 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 <img> 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;
}

return context.elementName == "img" &&
networkSchemas.contains(src.scheme) &&
(networkDomains == null || networkDomains!.contains(src.host)) &&
(extension == null || src.path.endsWith(".$extension"));

}

/// Matches an <img> tag with an svg asset image
Expand Down Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter_html_svg/test/svg_data_image_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
Expand Down

0 comments on commit 5ae5cc4

Please sign in to comment.