搜索插件、代码仓与 APP 分类

GitHub 代码仓leancodepl/dashed_line

虚线

用您想要的任何形状和样式绘制虚线。就这么简单。

虚线 项目封面
星标
25
复刻
4
最近推送(UTC)
2023年12月1日
项目状态
未归档

原始 README

以下为英文项目原文快照,最新内容请访问 GitHub。

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.

LeanCode GitHub avatar
GitHub 作者

LeanCode ↗

We're a custom software studio that delivers end-to-end solutions for various industries. Experts in Flutter, .NET, and React.

语言DartSwiftKotlinObjective-C

分类

此仓库发布的插件

使用的依赖

依赖清单 4 项

  • flutter{"sdk":"flutter"}
  • svg_path_parser^1.0.0
  • flutter_test开发依赖{"sdk":"flutter"}
  • lint开发依赖^1.5.3

如何选择适合项目的代码仓?

先按使用场景筛选,再比较项目活跃情况,最后到原始仓库核对使用要求。

  1. 通过仓库名、作者或描述搜索,再按技术分类缩小范围。
  2. 结合星标、复刻与最近推送比较项目;星标反映社区关注,不代表质量保证。
  3. 使用前在 GitHub 核对 README、许可证与 Issues。

来源与维护

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗