AnimatedReadMoreText

一个Flutter包,提供了一个可自定义的Widget,用于显示文本,并带有可选的“阅读更多/阅读更少”按钮,以增强文本密集型内容的用户体验。

概述

AnimatedReadMoreText Widget是一个Flutter包,它以一种用户友好且视觉上吸引人的方式呈现长文本内容。它根据预设的最大行数动态调整文本长度,确保在各种屏幕尺寸上的最佳可读性。该Widget的关键功能是能够根据用户交互无缝地扩展或折叠文本。此功能通过允许用户专注于文本的特定部分,而不会被长篇内容所淹没,从而提高了可读性。此外,该Widget的微妙而有影响力的动画为用户界面增添了一抹优雅,进一步增强了整体阅读体验。

AnimatedReadMoreText

特点

  • 轻量且易于使用
  • 以指定的行数为上限显示文本。
  • 为“阅读更多”和“阅读更少”按钮设置自定义标签,以匹配您的应用程序品牌并增强用户体验。
  • 外观和行为可自定义。
  • 支持文本和按钮的可选样式。
  • 文本扩展和折叠的平滑且可自定义的动画。

用法

要使用此包,请将其包含在您的pubspec.yaml文件中

dependencies:
  animated_read_more_text: ^0.0.6

在您的Dart文件中导入包

import 'package:animated_read_more_text/animated_read_more_text.dart';

在您的Flutter应用程序中使用AnimatedReadMoreText Widget

AnimatedReadMoreText(
  yourLongText,
  maxLines: 3,
  // Set a custom text for the expand button. Defaults to Read more
  readMoreText: 'Expand',
  // Set a custom text for the collapse button. Defaults to Read less
  readLessText: 'Collapse',
  // Set a custom text style for the main block of text
  textStyle: TextStyle(
    fontSize: 16,
    color: Colors.red,
  ),
  // Set a custom text style for the expand/collapse button
  buttonTextStyle: TextStyle(
    fontSize: 16,
    fontWeight: FontWeight.bold,
  ),
)

设置自定义动画曲线和持续时间

AnimatedReadMoreText(
  yourLongText,
  // Set the curve of the animation
  animationCurve: Curves.easeInOut,
  // Set the duration of the animation
  animationDuration: Duration(milliseconds: 500),
)

贡献

欢迎贡献和错误报告!请随时创建issue或提交pull request。

许可证

此包根据MIT许可证授权 – 详情请参阅LICENSE文件。

GitHub

查看 Github