Search packages, repositories and app categories

Package detailsv1.0.1

path_drawing

A flutter library to help with (Canvas) Path creation and manipulation

AndroidiOSWebmacOSWindowsLinux
30-day downloads
931K
Likes
223
Pub points
140

Install package

flutter pub add path_drawing

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

A Flutter library designed to simplify the creation and manipulation of Canvas Paths. It provides utility functions for generating common shapes, transforming paths, and performing geometric operations like offsetting, scaling, and combining paths. Ideal for developers working with custom drawing, animations, or complex vector graphics on any Flutter platform. The package enhances precision and reduces boilerplate when handling intricate path logic.

Use cases

  • Creating custom shapes in Canvas
  • Animating path transformations
  • Generating geometric patterns
  • Building vector-based UI components
  • Manipulating path geometry programmatically

Key features

  • Easy path construction utilities
  • Path transformation methods
  • Support for path intersections and unions
  • Cross-platform compatibility
  • Minimal dependency overhead

Suitable for

  • Flutter developers building custom graphics
  • UI designers implementing vector art
  • Animation creators needing path control
  • Apps requiring precise shape rendering

Considerations

  • Requires understanding of Canvas and Path concepts
  • Limited to path-specific operations
  • Not intended for full SVG rendering
  • Best used with custom painting widgets

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

path_drawing

pub package

A Flutter library to assist with creating and manipulating paths.

Currently supports parsing a Path from an SVG path data string (including normalizing the path commands to be amenable to Flutter's exposed Path methods).

Dash paths has an initial implementation that relies on flutter 0.3.6 at a minimum.

Planned for future release(s):

  • Trim paths

Example

Parse some path from svg string:

import 'package:path_drawing/path_drawing.dart';

final trianglePath = parseSvgPathData('M150 0 L75 200 L225 200 Z');

Create CustomPainter:

class FilledPathPainter extends CustomPainter {
  const FilledPathPainter({
    @required this.path,
    @required this.color,
  });

  final Path path;
  final Color color;

  @override
  bool shouldRepaint(FilledPathPainter oldDelegate) =>
      oldDelegate.path != path || oldDelegate.color != color;

  @override
  void paint(Canvas canvas, Size size) {
    canvas.drawPath(
      path,
      Paint()
        ..color = color
        ..style = PaintingStyle.fill,
    );
  }

  @override
  bool hitTest(Offset position) => path.contains(position);
}

Use it inside CustomPaint:

class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () => print('tap'),
      child: CustomPaint(
        painter: FilledPathPainter(
          path: trianglePath,
          color: Colors.blue,
        ),
      ),
    );
  }
}

More examples can be found in example folder

Categories

Dependencies

Dependency list 3 items

Source repository

Projects using this package