Skip to content

Instantly share code, notes, and snippets.

@parthdave93
Created July 1, 2020 18:38
Show Gist options
  • Save parthdave93/85fda4059cdcae0b6885f2ae6f0646ee to your computer and use it in GitHub Desktop.
Save parthdave93/85fda4059cdcae0b6885f2ae6f0646ee to your computer and use it in GitHub Desktop.
Flutter Web platform dependent code for Flutter_SVG plugin
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