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

插件详情v1.0.2

gradient_text

一个用于显示带有渐变效果文本的 Flutter 小部件。接受 TextStyle 和 TextAlign,因此可以非常类似于 Text 小部件使用。

近 30 天下载
82
喜欢数
31
Pub 分数
40

安装插件

flutter pub add gradient_text

插件介绍

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

一个 Flutter 小部件,用于渲染带有渐变效果的文本,允许开发者在单个字符或整个文本字符串上应用平滑的颜色过渡。它支持标准的 TextStyle 和 TextAlign 属性,使其与现有的文本样式工作流程兼容。非常适合创建视觉吸引力强的 UI 元素,如标题、按钮或标签,并带有动态颜色效果。该包轻量且易于集成,所需配置极少。

适合场景

  • 创建带有渐变效果的样式标题
  • 为应用按钮增添视觉魅力
  • 通过动态颜色过渡增强UI元素
  • 设计现代的启动屏幕
  • 在仪表板中实现动画文本

主要特点

  • 支持 TextStyle 和 TextAlign
  • 通过文本实现平滑渐变渲染
  • 所需设置最少
  • 轻量且高效
  • 与标准 Text widget 属性兼容

适合对象

  • 寻求视觉增强的UI设计师
  • 开发现代 Flutter 应用的开发者
  • 需要渐变文本但无需自定义绘制的项目
  • 注重美学吸引力的应用

使用建议

  • 仅限纯文本渐变(无背景效果)
  • 可能会影响大型文本块的性能
  • 渐变方向和停止点需要手动配置
  • 不适合用于具有多种样式的复杂文本布局

原始 README

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

GradientText

A Flutter Widget for displaying gradient text, text with a gradient drawn through it.

GradientTextScreenshot

Getting Started

Add the plugin (pub coming soon):

dependencies:
  ...
  gradient_text: ^1.0.2

Usage

Import it:

import 'package:gradient_text/gradient_text.dart';

Use it:

GradientText("this is my text",
    gradient: LinearGradient(
    colors: [Colors.deepPurple, Colors.deepOrange, Colors.pink]),
    style: TextStyle(fontSize: 42),
    textAlign: TextAlign.center);

Parameters:

data :: (required) :: The String to be used in the Text Widget

gradient :: (required) :: A gradient to be drawn through the text

style :: (optional) :: TextStyle to be used in the Text Widget. Color is ignored, as the text must be white to have the gradient drawn.

textAlign :: (optional) :: TextAlign to be used in the Text Widget. Default is left.

Credit

The idea to use ShaderMask came from Reddit user boformer. Thanks boformer.

所属分类

源码仓库

使用此插件的项目