搜索插件、代码仓与 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

所属分类

源码仓库

使用此插件的项目

所在榜单