Created
July 1, 2020 18:38
-
-
Save parthdave93/85fda4059cdcae0b6885f2ae6f0646ee to your computer and use it in GitHub Desktop.
Flutter Web platform dependent code for Flutter_SVG plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/foundation.dart'; | |
import 'package:flutter/material.dart'; | |
class PlatformSvg { | |
static Widget asset(String assetName, | |
{double width, | |
double height, | |
BoxFit fit = BoxFit.contain, | |
Color color, | |
alignment = Alignment.center, | |
String semanticsLabel}) { | |
if (kIsWeb) { | |
return Image.network("/assets/$assetName", | |
width: width, | |
height: height, | |
fit: fit, | |
color: color, | |
alignment: alignment, | |
semanticLabel: semanticsLabel); | |
} | |
return SvgPicture.asset(assetName, | |
width: width, | |
height: height, | |
fit: fit, | |
color: color, | |
alignment: alignment, | |
semanticsLabel: semanticsLabel, | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment