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

gradient_borders 封面
插件详情v1.0.4

gradient_borders

输入框和容器的渐变边框。边框包与基本的 Flutter 小部件(如容器和输入装饰)集成。使用简单,平台无关。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
19.3万
喜欢数
333
Pub 分数
160

安装插件

flutter pub add gradient_borders

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个为容器和输入字段添加渐变边框的 Flutter 包,通过平滑的颜色过渡提升视觉吸引力。设计简洁,兼容所有主要平台——Android、iOS、Web、macOS、Windows 和 Linux。可无缝集成到标准 Flutter 小部件(如 Container 和 InputDecoration)中,设置简单。适用于现代 UI 设计,通过微妙的渐变提升用户体验,而无需复杂操作。

适合场景

  • 为表单输入添加时尚边框
  • 增强卡片或容器的视觉效果
  • 在应用程序中创建现代用户界面元素
  • 使用渐变设计响应式布局
  • 自定义按钮或字段边框
  • 通过最少的代码提升应用美感

主要特点

  • 与 Container 和 InputDecoration 的轻松集成
  • 支持平滑的渐变过渡
  • 跨平台兼容性
  • 所需配置最少
  • 与现有 Flutter 小部件兼容
  • 无需额外依赖

适合对象

  • 寻求视觉增强的UI设计师
  • 开发现代移动或Web应用的开发者
  • 需要优雅边框效果的项目
  • 注重用户界面精炼的应用
  • 初学者探索 Flutter 装饰选项
  • 希望实现跨平台样式的团队

使用建议

  • 可能会影响低端设备在具有多个渐变边框时的性能
  • 除了渐变方向和颜色外,自定义选项有限
  • 不适合复杂的边框图案
  • 需要仔细考虑对比度以确保可读性
  • 建议谨慎使用,以避免视觉杂乱
  • 依赖于 Flutter 的渲染管道以确保一致性

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Gradient borders

style: very good analysis

Various borders that use gradient instead of boring plain colors.

Usage

Box borders:

Change your container borders to use fancy gradients:

Container(
  width: 100,
  height: 100,
  decoration: BoxDecoration(
    border: const GradientBoxBorder(
      gradient: LinearGradient(colors: [Colors.blue, Colors.red]),
      width: 4,
    ),
    borderRadius: BorderRadius.circular(16)
  ),
),

Works with both: border radius, and with BoxShape.circle

Parameters
Parameter Type Default Description
gradient Gradient required The gradient to use for the border color.
width double 1.0 The width of the border.
strokeAlign double BorderSide.strokeAlignInside The alignment of the stroke relative to the border edge. Use BorderSide.strokeAlignInside (-1), BorderSide.strokeAlignCenter (0), or BorderSide.strokeAlignOutside (1).

image

Input borders

You can use GradientOutlineInputBorder as a part of your input decoration:

TextField(
  decoration: InputDecoration(
    border: GradientOutlineInputBorder(
      gradient: LinearGradient(colors: [Colors.red, Colors.blue]),
      width: 2,
    ),
    focusedBorder: GradientOutlineInputBorder(
     gradient: LinearGradient(colors: [Colors.yellow, Colors.green]),
      width: 2
    ),
    label: Text("Example"),
  ),
),
Parameters
Parameter Type Default Description
gradient Gradient required The gradient to use for the border color.
width double 1.0 The width of the border.
gapPadding double 4.0 Horizontal padding around the label cutout in the border.
borderRadius BorderRadius BorderRadius.all(Radius.circular(4)) The border radius of the rounded corners.
borderAlignment OutlineBorderAlignment OutlineBorderAlignment.onEdge Controls where the stroke is drawn relative to the widget edge. onEdge draws the border centered on the widget boundary; inside draws it fully inside.

image

You can also use GradientUnderlineInputBorder as part of your input decoration:

TextField(
  decoration: InputDecoration(
    border: GradientOutlineInputBorder(
      gradient: LinearGradient(colors: [Colors.red, Colors.blue]),
      width: 2,
    ),
    focusedBorder: GradientUnderlineInputBorder(
     gradient: LinearGradient(colors: [Colors.yellow, Colors.green]),
      width: 2
    ),
    label: Text("Example"),
  ),
),
Sponsored by

The Code Brothers

所属分类

源码仓库

使用此插件的项目