Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/aloisdeniel/built_vector

Generate Flutter vector code from a subset of SVG files.
https://github.com/aloisdeniel/built_vector

dart flutter shape svg vector

Last synced: 4 months ago
JSON representation

Generate Flutter vector code from a subset of SVG files.

Awesome Lists containing this project

README

        

# built_vector

Generates Flutter vector code from minimalist SVG-like files.

## Usage

```sh
> pub global activate built_vector
> pub global run built_vector -i -o
```

A class named accordingly to your assets node's name, containing a `void Paint(Canvas canvas, Size size, {Color fill})` function for each vector node.

You can then use them with a custom painter, like with the [sample/lib/vectors.dart](sample/lib/vectors.dart) `Vector` widget.

## File format

### Assets

An asset catalog is a collection of assets (`vector` only at the moment).

```xml



```

### Vector

A vector is a collection of filled shapes.

It has several properties :

* `name` **(required)** : the identifier of the vector asset
* `viewBox` **(required)** : a box (` `)that contains all the shapes.
* `fill` : a default fill brush for shapes

```xml



```

### Shape

A shape is a set of instructions to build an area to fill with a brush. Currently it can be `rect`, `circle`, `path`.

It has several properties :

* `fill` : a default fill brush for shapes
* `rect` - `x`, `y`, `width`, `height` : position and size
* `circle` - `cx`, `cy`, `r` : center coordinates and radius
* `path` - `d` : SVG path data

```xml



```

## Sample

To generate the sample, execute :

```sh
> pub global run built_vector -i sample/assets/icons.assets -o sample/lib/icons.g.dart
```

The [sample/assets/icons.assets](sample/assets/icons.assets) file is generated as [sample/lib/icons.g.dart](sample/lib/icons.g.dart).