Draw dashed lines with any shape and style you want. Just like that.

Overview

dashed_line

pub.dev build status

Draw dashed lines with any shape and style you want. Just like that.

Usage

Add the dependency to your pubspec.yaml (you can see the newest version in the pub badge):

dependencies:
  dashed_line: ^0.1.0

Use the widget:

import 'package:dashed_line/dashed_line.dart';

// ...

DashedLine(
  path: Path()..cubicTo(-40, 53, 14, 86, 61, 102),
  color: Colors.red,
)

...you can also use the SVG path commands instead of a Path:

DashedLine.svgPath(
  'C -40 53 14 86 61 102',
  color: Colors.red,
)

Where to obtain path methods/commands?

There are many ways.

You can construct the path yourself using the Path methods like lineTo or cubicTo.

You can also use the path commands used in the d attribute of SVG files. You can do this manually or via export from one of the vector graphics software, like Inkscape or Figma. We found SvgPathEditor quite useful too.

Example: Exporting path commands from Figma

First step Second step
Create path using pen Export path as SVG

And now we have an SVG in the clipboard:

<svg width="190" height="48" viewBox="0 0 190 48" fill="none" xmlns="http://www.w3.org/2000/svg">
  <path d="M1 16C73 79 100 3 121 0.999997C142 -1 214.5 11.5 179 47" stroke="black"/>
svg>

From here we can just copy the value of the path's d attribute and use for the DashedLine.svgPath constructor's first argument.

🚨 Note about paths

Due to how Paths work in Flutter and Skia, the DashedLine widget takes NOT as much space as the dashed line needs, but as much it needs to contain all the control points. Table below should help understand the problem.

Path commands Path Result line
C 8 63 14 86 61 102
C -40 53 14 86 61 102

License

See LICENSE.

You might also like...

[reborned barcode_scan] A flutter plugin for reading 2D barcodes and QR codes.

Reborned 🎉 Original barcode_scan was discontinued, so barcode_scan2 was borned with sound null safety support 🎉 barcode_scan2 A flutter plugin for s

Jan 6, 2023

Maybe this is the best k chart in Flutter.Support drag,scale,long press,fling.And easy to use.

Maybe this is the best k chart in Flutter.Support drag,scale,long press,fling.And easy to use.

k_chart Maybe this is the best k chart in Flutter.Support drag,scale,long press,fling.And easy to use. display image gif Getting Started Install depen

Jan 9, 2023

Flutter chart library contains depth charts supporting various indicators and zooming

Flutter chart library contains depth charts supporting various indicators and zooming

flutter_k_chart 介绍 一个仿火币的flutter图表库包含深度图,支持各种指标及放大缩小、平移等操作 webdemo演示 Demo v0.1.0:下载 APK 演示 简单用例 1.在 pubspec.yaml 中添加依赖 本项目数据来自火币openApi,火币的接口可能需要翻墙,接口

Dec 30, 2022

Flutter GraphView is used to display data in graph structures. It can display Tree layout, Directed and Layered graph. Useful for Family Tree, Hierarchy View.

Flutter GraphView is used to display data in graph structures. It can display Tree layout, Directed and Layered graph. Useful for Family Tree, Hierarchy View.

GraphView Get it from | Flutter GraphView is used to display data in graph structures. It can display Tree layout, Directed and Layered graph. Useful

Jan 6, 2023

Stores and manages the data of your week expenses with a chart

personal_expenses_app A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you st

Dec 26, 2021

A simple candlestick chart for flutter. Supports smooth scroll and zoom

simple_candlestick_chart A simple candlestick chart for flutter. Supports smooth

Oct 17, 2022

This package allows you to draw dotted lines with Flutter. You can draw a beautiful dotted line.

This package allows you to draw dotted lines with Flutter. You can draw a beautiful dotted line.

This package allows you to draw dotted lines with Flutter. You can draw a beautiful dotted line.

Feb 9, 2022

Flutter library to add gestures and animations to each Shape you draw on your canvas in your CustomPainter

Flutter library to add gestures and animations to each Shape you draw on your canvas in your CustomPainter

Flutter library to bring your CustomPainter 🎨 to Life ✨ ⚡️ touchable library gives you the ability to add various gestures and animations to each Sha

Jan 7, 2023

This package allows you to draw dotted lines with Flutter.

This package allows you to draw dotted lines with Flutter.

About This package allows you to draw dotted lines with Flutter. Usage Parameter Default Description direction Axis.horizontal The direction of the en

Nov 16, 2022

Draw perfect freehand lines—in Flutter.

Draw perfect freehand lines—in Flutter.

Draw perfect pressure-sensitive freehand lines. 🔗 A port of the perfect-freehand JavaScript library. Try out that demo. 💕 Love this library? Conside

Jan 2, 2023

Draw perfect freehand lines—in Flutter.

Draw perfect freehand lines—in Flutter.

Draw perfect pressure-sensitive freehand lines. 🔗 A port of the perfect-freehand JavaScript library. Try out that demo. 💕 Love this library? Conside

Dec 8, 2022

This pub lets you share any kind of files (csv, mp4, png etc), take screenshot of the widgets you want and return as Image and share them directly as well in the form of an image.

share_files_and_screenshot_widgets This pub lets you share any kind of files (csv, mp4, png etc), take screenshot of the widgets you want and return a

Dec 28, 2022

This project is used to introduce the use of flutter canvas, include draw chart, clip image's path and draw progress indicator.

This project is used to introduce the use of flutter canvas, include draw chart, clip image's path and draw progress indicator.

flutter_canvas This project is used to introduce the use of flutter canvas, include draw chart, clip image's path and draw progress indicator. draw ch

Oct 27, 2022

Like Button is a flutter library that allows you to create a button with animation effects similar to Twitter's heart when you like something and animation effects to increase like count.

Like Button is a flutter library that allows you to create a button with animation effects similar to Twitter's heart when you like something and animation effects to increase like count.

like_button Language: English | 中文简体 Like Button is a flutter library that allows you to create a button with animation effects similar to Twitter's h

Dec 27, 2022

It's a universal app template to have a great animated splash screen and liquid slider. Just change the animation if you want (rive) and change the images or colours according to your app.

liquid A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if this i

Oct 7, 2022

Flutter plugin to simply integrate Agora Video Calling or Live Video Streaming to your app with just a few lines of code.

Agora UI Kit for Flutter Instantly integrate Agora video calling or video streaming into your Flutter application. Getting started Requirements An Ago

Dec 16, 2022

A Flutter slidable widget that provides an easy to use configuration. Highly customisable. Just as you want it!

A Flutter slidable widget that provides an easy to use configuration. Highly customisable. Just as you want it!

A Flutter slidable widget that provides an easy to use configuration. Highly customisable. Just as you want it!

Dec 8, 2022

This is a Flutter Food Recipe App this shows food recipes of any food which you want.

food_recipe_app A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started

Oct 31, 2022
Comments
  • Path()..moveTo() not working as intended with package?

    Path()..moveTo() not working as intended with package?

    I'm trying to draw a dashed arc, however it appears that the Path()..moveTo() is not working as intended with the package.

    Container(
      width: SizeConfig.safeScreenWidth!,
      height: SizeConfig.safeScreenHeight! * 4 / 9,
      child: DashedLine(
        path: Path()
          ..moveTo(
            SizeConfig.safeScreenWidth! * 0.2,
            (SizeConfig.safeScreenHeight! * 4 / 9) * 0.7,
          )
          ..quadraticBezierTo(
            SizeConfig.safeScreenWidth! * 0.5,
            (SizeConfig.safeScreenHeight! * 4 / 9) * 0.3,
            SizeConfig.safeScreenWidth! * 0.8,
            (SizeConfig.safeScreenHeight! * 4 / 9) * 0.7,
          ),
        dashSpace: 1,
        color: Colors.grey,
      )
    )
    

    This is the resulting curve: Screenshot 2021-04-09 at 18 33 45

    However, I'd like for the curve to start from 20% of the screen width, and end at 80% of the screen width, like this: Screenshot 2021-04-09 at 18 38 09

    which I achieved using the same path methods.

    opened by 15tariqj 3
  • Taking actual visible space

    Taking actual visible space

    First up, this is a really cool package! Thanks for creating it ❤️

    Use case

    It would be useful if the DashedLine widget was the same size as the visible dashed line instead of the size of the control points.

    Proposal

    Add option to the DashedLine widget to take up the size that the displayed path will take up.

    Current note

    I am aware of the note you added to your README, however, I actually think it is somewhat misleading:

    Due to how Paths work in Flutter and Skia, the DashedLine widget takes NOT as much space as the dashed line needs, but as much it needs to contain all the control points.

    This suggests that this is a limit of the Flutter rendering engine while it is obviously not. You are free to define the size of your render objects however you please.

    Implementation

    I assume you are using Path.getBounds for the bounds of your DashedLine widget (I have not looked into the implementation).

    This, of course, returns the control points. I am not sure if Path.computeMetrics makes figuring out the actual visible bounds any easier, but you can always calculate it yourself if the existing implementation does not provide it for you.
    This is clearly possible and probably also fairly trivial (considering the existing work on bezier curves et al.)

    opened by creativecreatorormaybenot 0
Releases(v0.1.0+1)
Owner
LeanCode
We build custom digital products for any type of business (marketplaces, content, ecommerce) in all geographies (USA, Europe, Middle East, Australia & China).
LeanCode
A library to draw fantastic bar charts race in Flutter

bar_chart_race The first library to draw fantastic bar charts race in Flutter Usage Let's get started add the dependencies to your app: dependencies:

Mimene Younes 6 Jun 24, 2022
Just for learning.

flutter-chart-http ❤️ Star ❤️ the repo to support the project or ?? Follow Me.Thanks! Facebook Page Facebook Group QQ Group Developer Flutter Open Flu

niebin 32 Aug 1, 2021
Track your habits day by day and check your result like the GitHub's contributions board

Habits Diary Track your habits day by day and see your result like the GitHub's contributions board Download Support If you want to support this proje

Pigna 25 Oct 27, 2022
In this project you will see how to generate charts with the data from the Firestore.

FlutterChartFirestore Flutter Tutorial - Flutter Charts+Firestore Video series can be watched here https://youtu.be/HGkbPrTSndM Getting Started In thi

Whatsupcoders 49 Oct 21, 2022
A powerful 🚀 Android chart view / graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, panning and animations.

⚡ A powerful & easy to use chart library for Android ⚡ Charts is the iOS version of this library Table of Contents Quick Start Gradle Maven Documentat

Philipp Jahoda 36k Dec 28, 2022
Animated radial and pie charts for Flutter

Flutter Circular Chart A library for creating animated circular chart widgets with Flutter, inspired by Zero to One with Flutter. Overview Create easi

Victor Choueiri 387 Dec 26, 2022
Elegant OHLC Candlestick and Trade Volume charts for @Flutter

flutter_candlesticks Elegant OHLC Candlestick and Trade Volume charts for Flutter Usage Install for Flutter with pub. Property Description data Requir

Trent Piercy 402 Dec 21, 2022
:bar_chart: [wip] Create beautiful, responsive, animated charts using a simple and intuitive API.

fcharts A work-in-progress chart library for Flutter. Until version 1.0.0 the API is subject to change drastically. Needless to say, fcharts is not pr

Keenan Thompson 323 Dec 21, 2022
A powerful Flutter chart library, currently supporting Line Chart, Bar Chart, Pie Chart, Scatter Chart and Radar Chart.

FL Chart ?? A library to draw fantastic charts in Flutter ?? Chart Types LineChart BarChart PieChart Read More Read More Read More ScatterChart RadarC

Iman khoshabi 5.2k Dec 27, 2022
A beautiful bezier line chart widget for flutter that is highly interactive and configurable.

Bezier Chart A beautiful bezier line chart widget for flutter that is highly interactive and configurable. Features Multi bezier lines Allow numbers a

Aeyrium 428 Dec 21, 2022