toSvg method
Renders symbol as an SVG document drawn with this style: the
colors, gradient, module and finder shapes and logo of BarcodeView.
The viewBox is in modules; width and height are pixels:
moduleSize pixels per module (4 by default), or size pixels across
the longer side. The logo is embedded as a PNG. Asynchronous because
the logo is loaded first. See Exports in the class description for
fonts and logos.
Throws UnsupportedError for a SweepGradient, which SVG cannot
draw: use toPng for it, or a LinearGradient or RadialGradient.
Throws ArgumentError if both size and moduleSize are given, one
is not positive, or size is smaller than the image in modules.
In debug mode, asserts that a QR code under a logo has the error correction the logo needs (see encode).
final symbol = await style.encode('https://pub.dev');
await File('qr.svg').writeAsString(await style.toSvg(symbol, size: 512));
Implementation
Future<String> toSvg(BarcodeSymbol symbol, {int? size, int? moduleSize}) =>
styledSvg(symbol, this, size: size, moduleSize: moduleSize);