Skip to content

Instantly share code, notes, and snippets.

@xxGus
Created July 29, 2019 18:03
Show Gist options
  • Save xxGus/11b8954a5736a4e772d14d2a52d3f527 to your computer and use it in GitHub Desktop.
Save xxGus/11b8954a5736a4e772d14d2a52d3f527 to your computer and use it in GitHub Desktop.
Flutter: adding SVG
final String assetName = 'assets/image.svg';
final Widget svg = new SvgPicture.asset(
assetName,
semanticsLabel: 'Acme Logo'
);
final String assetName = 'assets/up_arrow.svg';
final Widget svgIcon = new SvgPicture.asset(
assetName,
color: Colors.red,
semanticsLabel: 'A red up arrow'
);
// Will print error messages to the console.
final String assetName = 'assets/image_that_does_not_exist.svg';
final Widget svg = new SvgPicture.asset(
assetName,
);
final Widget networkSvg = new SvgPicture.network(
'https://site-that-takes-a-while.com/image.svg',
semanticsLabel: 'A shark?!',
placeholderBuilder: (BuildContext context) => new Container(
padding: const EdgeInsets.all(30.0),
child: const CircularProgressIndicator()),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment