Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

dashed_line

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
figma-step1 figma-step2

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 path-inside-bbox path-inside-bbox-result
c -40 53 14 86 61 102 path-outside-bbox path-outside-bbox-result

Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Comments are closed.