Skip to content

Commit

Permalink
doc updates
Browse files Browse the repository at this point in the history
  • Loading branch information
dnfield committed May 15, 2018
1 parent 1709fa2 commit 6157550
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 9 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,13 @@
# CHANGES

## 0.1.3

- Add more unit tests and rendering tests (!).
- Add top level flutter_svg.dart.
- Fix bugs found in transform matrix logic for skewX and skewY.
- Minor improvements in handling inheritence for PathFillType.
- Support gradient spread types (TileModes in Flutter).

## 0.1.2

- Bump to path_drawing 0.2.3 (fix arc defect).
Expand Down
37 changes: 31 additions & 6 deletions README.md
@@ -1,13 +1,11 @@
# flutter_svg

[![Build Status](https://travis-ci.org/dnfield/flutter_svg.svg?branch=master)](https://travis-ci.org/dnfield/flutter_svg)
[![Build Status](https://travis-ci.org/dnfield/flutter_svg.svg?branch=master)](https://travis-ci.org/dnfield/flutter_svg) [![Coverage Status](https://coveralls.io/repos/github/dnfield/flutter_svg/badge.svg?branch=master)](https://coveralls.io/github/dnfield/flutter_svg?branch=master)

[![Coverage Status](https://coveralls.io/repos/github/dnfield/flutter_svg/badge.svg?branch=master)](https://coveralls.io/github/dnfield/flutter_svg?branch=master)
<img src="/../master/assets/flutter_logo.svg?sanitize=true" width="200px" alt="Flutter Logo which can be rendered by this package!">

Draw SVG and Android VectorDrawable (XML) files on a Flutter Widget.

<img src="/../master/assets/flutter_logo.svg?sanitize=true" width="200px" alt="Flutter Logo">

## Getting Started

This is a Dart-native rendering library. Issues/PRs will be raised in Flutter
Expand All @@ -18,6 +16,12 @@ done by Skia; for example, the Path parsing logic here isn't much slower than
doing it in native, and Skia isn't always doing low level GPU accelerated work
where you might think it is (e.g. Dash Paths).

All of the SVGs in the `assets/` folder (except the text related one(s)) now
have corresponding PNGs in the `golden/` folder that were rendered using
`flutter test tool/gen_golden.dart` and compared against their rendering output
in Chrome. Automated tests will continue to compare these to ensure code
changes do not break known-good renderings.

Basic usage (to create an SVG rendering widget from an asset):

```dart
Expand All @@ -28,13 +32,34 @@ final Widget svg = new SvgImage.asset(
);
```

If you'd like to render the SVG to some other canvas, you can do something like:

```dart
import 'package:flutter_svg/flutter_svg.dart' as svg;
final svg.DrawableRoot svgRoot = await svg.loadAsset('assets/image.svg');
// Optional, but probably normally desireable: scale the canvas dimensions to
// the SVG's viewbox
svgRoot.scaleCanvasToViewBox(canvas);
// Optional, but probably normally desireable: ensure the SVG isn't rendered
// outside of the viewbox bounds
svgRoot.clipCanvasToViewBox(canvas);
svgRoot.draw(canvas, size);
```

While I'm making every effort to avoid needlessly changing the API, it's not
guarnateed to be stable yet (hence the pre-1.0.0 version).

See [main.dart](/../master/example/main.dart) for a complete sample.

## Use Cases

- Your designer creates a vector asset that you want to include without converting to 5 different
raster format resolutions.
- Your vector drawing is meant to be static and non (or maybe minimally) interactive
- Your vector drawing is meant to be static and non (or maybe minimally) interactive.
- You want to load SVGs dynamically from network sources at runtime.
- You want to paint SVG data and render it to an image.

## TODO

Expand All @@ -48,7 +73,7 @@ or where I've gotten a request to fix something/example of something that's brok
- [ ] More SVG samples to cover more complicated cases (getting there - please send me samples of
things that don't work!).
- [ ] Display/visibility support.
- [ ] Unit tests. In particular, tests that validate XML -> Drawable* structures.
- [ ] Unit tests. In particular, tests that validate XML -> Drawable* structures. (Vastly improved as of 0.2.)
- [ ] Inheritance of inheritable properties (~~necessary? preprocess?~~ significant progress).
- [ ] Support for minimal CSS/styles? See also
[svgcleaner](https://github.com/razrfalcon/svgcleaner) (partial - style attr mostly supported).
Expand Down
3 changes: 1 addition & 2 deletions example/main.dart
@@ -1,7 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/avd.dart';
import 'package:flutter_svg/vector_drawable.dart';
import 'package:flutter_svg/svg.dart';
import 'package:flutter_svg/flutter_svg.dart';

const List<String> assetNames = const <String>[
'assets/flutter_logo.svg',
Expand Down
3 changes: 3 additions & 0 deletions lib/flutter_svg.dart
@@ -0,0 +1,3 @@
export 'src/vector_painter.dart';
export 'svg.dart';
export 'vector_drawable.dart';
2 changes: 1 addition & 1 deletion pubspec.yaml
Expand Up @@ -2,7 +2,7 @@ name: flutter_svg
description: An SVG rendering and widget library for Flutter.
author: Dan Field <dfield@gmail.com>
homepage: https://github.com/dnfield/flutter_svg
version: 0.1.2
version: 0.1.3

dependencies:
path_drawing: ^0.2.3
Expand Down

0 comments on commit 6157550

Please sign in to comment.