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

dotted_border 封面
套件詳情v3.1.0

dotted_border

一個 Flutter 套件,讓使用者能輕鬆為任何組件加上虛線邊框。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
92.4萬
喜歡數
1650
Pub 分數
160

安裝套件

flutter pub add dotted_border

套件介紹

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

dotted_border 套件為 Flutter 中的任何組件提供了一種簡單的方式來新增虛線邊框。它允許開發者透過顏色、筆畫寬度、虛線長度和間距長度等選項自訂邊框外觀。此套件非常適合建立視覺上吸引人的 UI 元素,例如需要虛線或點線輪廓的輸入欄位、按鈕或容器。它支援所有主要平台,包括 Android、iOS、Web、macOS、Windows 和 Linux,確保跨裝置的一致性樣式。

適用情境

  • 向輸入欄位添加虛線輪廓
  • 建立樣式化容器邊框
  • 設計互動式按鈕強調
  • 增強表單元素的視覺反饋
  • 使用虛線邊框建構自訂 UI 組件

主要特色

  • 可自訂的點大小與間距
  • 支援多邊框邊
  • 與現有組件的輕鬆整合
  • 跨平台相容性
  • 靈活的顏色和筆畫寬度設定

適合對象

  • 尋求裝飾性邊框的UI設計師
  • 開發表單介面的開發者
  • 需要在焦點狀態提供視覺反饋的應用程式
  • 需要在跨平台環境中保持一致虛線樣式的專案
  • 使用 Flutter 開發多平台應用的團隊

使用建議

  • 可能影響許多嵌套邊框的效能
  • 僅限邊框裝飾(不含內容裁剪)
  • 需要手動處理與其他裝飾的邊框重疊問題
  • 不適合超出基本矩形的複雜形狀邊框
  • 最佳搭配輕量級小部件使用,以維持流暢的呈現

原始 README

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

Dotted Border

pub package

A flutter package to easily add dotted borders around widgets.

Installing

To use this package, add dotted_border as a dependency in your pubspec.yaml file.

Usage

Wrap DottedBorder widget around the child widget

DottedBorder(
  child: Text(
    'Rectangular Border',
    style: TextStyle(
      fontWeight: FontWeight.bold,
    ),
  ),
)
BorderTypes

This package supports the following border options

  • CustomPath
  • RoundedRect
  • Rect
  • Circular
  • Oval
Example
DottedBorder(
  options: RectDottedBorderOptions(
    dashPattern: [10, 5],
    strokeWidth: 2,
    padding: EdgeInsets.all(16),
  ),
  child: Text(
    'Rectangular Border',
    style: TextStyle(
      fontWeight: FontWeight.bold,
    ),
  ),
)
Dash Pattern

You can also specify the Dash Sequence by passing in an Array of Doubles

Example
RectDottedBorderOptions(
  dashPattern: [10, 5],
  strokeWidth: 2,
  padding: EdgeInsets.all(16),
)

The above code block will render a dashed border with the following pattern:

  • 10 pixel wide dash
  • 5 pixel wide space
Custom Path Border

You can also specify a customPath property and it will draw it for you using the provided dash pattern.

Example
DottedBorder(
  options: CustomPathDottedBorderOptions(
    padding: const EdgeInsets.all(8),
    color: Colors.purple,
    strokeWidth: 2,
    dashPattern: [10, 5],
    customPath: (size) => Path()
      ..moveTo(0, size.height)
      ..relativeLineTo(size.width, 0),
  ),
  child: const Text(
    'Custom Path Border',
    style: TextStyle(
      color: Colors.purple,
      fontWeight: FontWeight.bold,
    ),
  ),
)
Output

Flutter dotted border image

Credits

所屬分類

原始碼儲存庫

使用此套件的專案

所在榜單