svg_painter 0.2.0 copy "svg_painter: ^0.2.0" to clipboard
svg_painter: ^0.2.0 copied to clipboard

A code generator that compiles SVG files into Flutter CustomPainter code.

example/example.dart

import 'package:svg_painter_annotation/svg_painter_annotation.dart';

part 'example.g.dart';

/// Example: Generate a CustomPainter from inline SVG code.
///
/// 1. Annotate a class with `@SvgPainter.code()`:
@SvgPainter.code('''
<svg viewBox="0 0 100 100">
  <circle cx="50" cy="50" r="40" fill="blue"/>
</svg>
''')
class _CirclePainter {}

/// 2. Run `dart run build_runner build`
///
/// 3. Use the generated painter in a Flutter app:
/// ```dart
/// CustomPaint(
///   size: const Size(100, 100),
///   painter: CirclePainter(),
/// )
/// ```

/// You can also use `@SvgPainter.file()` for SVG files:
/// ```dart
/// @SvgPainter.file('assets/icons/star.svg')
/// class _StarPainter {}
/// ```
1
likes
160
points
149
downloads

Publisher

unverified uploader

Weekly Downloads

A code generator that compiles SVG files into Flutter CustomPainter code.

Homepage
Repository (GitHub)
View/report issues
Contributing

Documentation

API reference

License

MIT (license)

Dependencies

analyzer, build, code_builder, dart_style, meta, path, source_gen, svg_painter_annotation, xml

More

Packages that depend on svg_painter