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

flutter_numeric_text 封面
插件详情v1.3.3

flutter_numeric_text

此控件可让您对任何文本进行动画处理。该控件易于使用,可无缝将 Text(data) 替换为 NumericText(data)。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
945
喜欢数
28
Pub 分数
160

安装插件

flutter pub add flutter_numeric_text

插件介绍

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

flutter_numeric_text 是一个 Flutter 包,可为文本显示启用平滑的数字动画。它用带有动画效果的数字过渡替换标准 Text 小部件,非常适合用于计数器、分数或任何随时间变化的数值。该小部件易于集成——只需将 Text(data) 替换为 NumericText(data)—并支持所有主要平台,包括 Android、iOS、Web、macOS、Windows 和 Linux。它提供无缝的视觉体验,设置简单,非常适合需要流畅数字更新的动态 UI 元素。

适合场景

  • 动画计数器
  • 分数显示
  • 动态数据可视化
  • 实时数字更新
  • 交互式仪表板

主要特点

  • 平滑数值动画
  • 简单 API 替代
  • 跨平台支持
  • 最小配置
  • 可自定义速度
  • 自动数字处理

适合对象

  • 需要动画数字的开发人员
  • UI设计师提升仪表板
  • 具有实时指标的应用程序
  • 游戏化功能
  • 简单而精致的动画

使用建议

  • 最适合数值类型
  • 可能会影响高频更新时的性能
  • 限于整数和小数
  • 不适用于非数字文本
  • 需要仔细调整以适应非常快速的更新

原始 README

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

Text(data) → NumericText(data)

This widget allows you to animate any text. The animation is reminiscent of the text animation in SwiftUI's .numericText(value:). The widget is easy to use and allows you to seamlessly replace Text(data) with NumericText(data).

Features

  • Automatic text animation
  • Minimal configuration required to get started
  • Supports almost all parameters of the Text() widget
  • No external dependencies required

Usage

import 'package:flutter_numeric_text/flutter_numeric_text.dart';

class MyWidget extends StatelessWidget {
  const MyWidget({super.key});

  @override
  Widget build(BuildContext context) {
    // Simply add the widget, and when its value changes,
    // it will automatically trigger the animation.

    // To use the widget, you only need to provide
    // a data value, other fields are optional.

    NumericText(
      "12345 or text",
      duration: const Duration(milliseconds: 300),
      style: const TextStyle(fontSize: 24, color: Colors.black),
      textAlign: TextAlign.center,
      textDirection: TextDirection.ltr,
      locale: const Locale("en", "US"),
      softWrap: true,
      overflow: TextOverflow.ellipsis,
      maxLines: 1,
      semanticsLabel: "Numeric value",
    );
  }
}
With GoogleFonts
...
    NumericText(
      "12345 or text",
      duration: const Duration(milliseconds: 300),
      style: GoogleFonts.<your_font>(
        fontSize: 24,
        color: Colors.black,
        // Just a friendly reminder to add the [textStyle] field.
        // It'll make sure everything calculates correctly.
        textStyle: Theme.of(context).textTheme.bodyMedium,
      ),
    );
...

Installation

To use this package, add it to your pubspec.yaml file:

dependencies:
  flutter_numeric_text: ^1.0.0 # Replace with the latest version

Contributing

Contributions are welcome! If you have suggestions for improvements or find bugs, please open an issue or submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

所属分类

源码仓库

使用此插件的项目

暂无相关数据。