painter_from_svg 0.0.1 copy "painter_from_svg: ^0.0.1" to clipboard
painter_from_svg: ^0.0.1 copied to clipboard

A Flutter CLI for generating icon files based on CustomPainter for `.svg` files.

A Flutter CLI for generating icon files based on CustomPainter for .svg files. Built to solve personal development challenges.

Features #

In current version:

  • parses basic SVG files (supports multiple paths, fill/stroke properties) and generates .dart files with classes which extends CustomPainter and paints the icon Note: Currently supports a subset of SVG features (no groups, transforms, or basic shapes)
  • generates general file with an abstract final class acting as a centralized icon provider and CustomIcon widget for seamless integration into Flutter UIs

CustomIcon automatically inherits IconThemeData from the build context, applying the same color, size, and styling as standard Flutter icons. This means that your custom icons work like Flutter’s built-in Icon(), respects IconTheme and ThemeData settings.

Getting started #

Install #

You can run the command in terminal or add dependency to pubspec.yamlmanually.

flutter pub add dev:painter_from_svg

Usage #

Simply run

dart run painter_from_svg:generate_icons 

or

flutter run painter_from_svg:generate_icons 

in the terminal

Configuration #

Default configuration:

  • Source: assets/icons/**.svg
  • Output: lib/generated/ (.g.dart files)
    • custom_icons.dart (main registry)
    • icons/ folder (individual painters)

You can customize build options via icons.yaml in project root or with CLI flags/arguments. CLI flags and argument will override icons.yaml values.

Customizable settings:

  • .svg source folder
  • output folder for generation
  • name of folder with individual painters
  • include or not .g. in extension
For build.yaml:
  • input: <path-from-project-root> -- for .svg source folder
  • output: <path-from-project-root> -- for output folder
  • output-icons: <folder-name> -- name of folder with individual painters
  • gen: true or gen: false for include or not .g. in extension
For CLI:
  • -i <path-from-project-root> or --input <path-from-project-root> -- for .svg source folder
  • -o <path-from-project-root> or --output <path-from-project-root> -- for output folder
  • -f <folder-name> or --output-icons <folder-name> -- name of folder with individual painters
  • -g, --[no-]gen flags for include or not .g. in extension
  • -h, --help flag for help message

Additional information #

Built to solve personal development challenges. You don't need this generator more than dev-dependency. I don't know yet about future maintenance of this package.

2
likes
120
points
16
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A Flutter CLI for generating icon files based on CustomPainter for `.svg` files.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

args, code_builder, dart_style, flutter, glob, path, xml, yaml

More

Packages that depend on painter_from_svg