Skip to content

fmaerkl-sw/flutter_built_path

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Built Path

This library can help Flutter applications pre-compile SVG Path data into Flutter (dart:ui) Path objects.

For example:

import 'package:built_path_annotations/built_path_annotations.dart';

part 'example.svg_path.g.dart';

@SvgPath('M10 10 L20 20 Z')
Path get diagonalLine => _$diagonalLine;

Will generate Dart code like the following:

part of 'example.dart'

Path __$diagonalLine;
Path get _$diagonalLine => __$diagonalLine ??
  (__$diagonalLine = new Path()
                      ..moveTo(10.0, 10.0)
                      ..lineTo(20.0, 20.0)
                      ..close());

Note that for a Flutter project, you'll have to run flutter packages pub run build_runner build. Follow flutter/flutter#13360, as this syntax may change in a future version of Flutter.

Also note that there will be an error reported about dart:ui until dart-lang/build#733 is resolved, but the code should still get generated.

The example/ folder contains a full working example for Flutter, including the build.yaml and generated code.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dart 88.0%
  • Objective-C 8.1%
  • Java 3.9%