built_vector 0.1.0

  • README.md
  • Installing
  • Versions
  • new37

built_vector

Generates Flutter vector code from minimalist SVG-like files.

Usage

> pub global activate built_vector
> pub global run built_vector -i <assets file path> -o <output dart file>

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 Vector widget.

File format

Assets

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

<assets name="icons">
    <vector ... />
    <vector ... />
    <vector ... />
</assets>

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 (<x> <y> <width> <height>)that contains all the shapes.
  • fill : a default fill brush for shapes
<vector name="warning" viewBox="0 0 24 24" fill="#231F20">
    <rect ... />
    <circle ... />
    <path ... />
</vector>

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
<vector name="warning" viewBox="0 0 24 24" fill="#231F20">
    <rect x="15" y="14" width="31" height="28" />
    <circle cx="45.5" cy="42.5" r="15.5" fill="#C4C4C4" />
    <path d="M12 17C12.5523 17 13 16.5523 13 16C13 15.4477 12.5523 15 12 15C11.4477 15 11 15.4477 11 16C11 16.5523 11.4477 17 12 17Z" />
</vector>

Sample

To generate the sample, execute :

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

The sample/assets/icons.assets file is generated as sample/lib/icons.g.dart.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  built_vector: ^0.1.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:built_vector/generator.dart';
import 'package:built_vector/model.dart';
import 'package:built_vector/parser.dart';
  
Version Uploaded Documentation Archive
0.1.0 Nov 14, 2018 Go to the documentation of built_vector 0.1.0 Download built_vector 0.1.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
90
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
50
Overall:
Weighted score of the above. [more]
37
Learn more about scoring.

We analyzed this package on Dec 5, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.7

Platforms

Detected platforms: Flutter, other

Platform components identified in package: io.

Health issues and suggestions

Document public APIs (-10 points)

38 out of 38 API elements (library, class, field or method) have no adequate dartdoc content. Good documentation improves code readability and discoverability through search.

Format bin/built_vector.dart.

Run dartfmt to format bin/built_vector.dart.

Format lib/generator.dart.

Run dartfmt to format lib/generator.dart.

Format lib/model.dart.

Run dartfmt to format lib/model.dart.

Format lib/parser.dart.

Run dartfmt to format lib/parser.dart.

Maintenance issues and suggestions

Maintain CHANGELOG.md. (-20 points)

Changelog entries help clients to follow the progress in your code.

The description is too short. (-20 points)

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use built_vector.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
args ^1.5.1 1.5.1
code_builder ^3.1.3 3.1.3
dart_style ^1.2.0 1.2.0 1.2.1
path_parsing ^0.1.3 0.1.3
recase ^2.0.0 2.0.0+1
source_gen ^0.9.1 0.9.1+3
xml ^3.2.3 3.2.3
Transitive dependencies
analyzer 0.33.6 0.34.0
async 2.0.8
build 1.0.1
built_collection 4.1.0
built_value 6.1.6
charcode 1.1.2
collection 1.14.11
convert 2.0.2
crypto 2.0.6
csslib 0.14.6
fixnum 0.10.9
front_end 0.1.6+8 0.1.7
glob 1.1.7
html 0.13.3+3
kernel 0.3.6+8 0.3.7
logging 0.11.3+2
matcher 0.12.4
meta 1.1.6
package_config 1.0.5
path 1.6.2
petitparser 2.0.2
plugin 0.2.0+3
pub_semver 1.4.2
quiver 2.0.1
source_span 1.4.1
stack_trace 1.9.3
string_scanner 1.0.4
typed_data 1.1.6
utf 0.9.0+5
vector_math 2.0.8
watcher 0.9.7+10
yaml 2.1.15