搜尋套件、儲存庫與 APP 分類

dashed_line 封面
套件詳情v0.1.0+3

dashed_line

用您想要的任何形狀和樣式繪製虛線。就這樣。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
6
喜歡數
77
Pub 分數
160

安裝套件

flutter pub add dashed_line

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個用於繪製可自訂虛線的 Flutter 套件,支援任意形狀或樣式。它讓開發者能輕鬆建立視覺上吸引人的虛線路徑,支援多種設定,例如虛線長度、間隙大小與筆畫寬度。非常適合用於跨平台應用中的分隔線、邊框或裝飾性線條等 UI 元素。此套件輕量且可順暢整合至現有的 Flutter 專案中。

適用情境

  • 在UI佈局中建立自訂分隔符
  • 設計裝飾性線條圖案
  • 在小部件周圍繪製虛線邊框
  • 增強圖表或圖形可視化
  • 建構互動式繪圖工具

主要特色

  • 支援任何路徑形狀
  • 可自訂的虛線與間距長度
  • 可調節的描邊寬度
  • 跨平台相容性
  • 簡單的 API 結合

適合對象

  • 尋求視覺多樣性的UI設計師
  • 開發資料視覺化組件的開發者
  • 需要樣式化裝飾元素的應用程式
  • 跨平台 Flutter 應用程式

使用建議

  • 可能需要對複雜路徑進行效能優化
  • 限制為在 Flutter 的畫布內進行 2D 渲染
  • 不適用於無額外邏輯的動畫儀錶效果

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

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.

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。