一种以不同方式显示溢出文本的插件

安装

1. 依赖它

将此添加到您的包的 pubspec.yaml 文件中

dependencies:
  overflow_text_animated: ^0.0.5

2. 安装它

您可以从命令行安装包

使用 pub

$ pub get

使用 Flutter

$ flutter pub get

3. 导入它

现在,在您的 Dart 代码中,您可以使用

import 'package:overflow_text_animated/overflow_text_animated.dart';

用法

OverflowTextAnimated是一个有状态小部件。像这样把它包含在你的build方法里:

OverflowTextAnimated(
  text: overflowText,
  style: descriptionStyle,
  curve: Curves.fastEaseInToSlowEaseOut,
  animation: OverFlowTextAnimations.scrollOpposite,
  animateDuration: Duration(milliseconds: 1500),
  delay: Duration(milliseconds: 500),
)

OverflowTextAnimated用作默认文本小部件。它有很多可配置的属性,包括:

  • text – 必需属性
  • style – 文本样式
  • curve – 动画效果的运动曲线
  • animation – 动画类型
  • animateDuration – 是动画的持续时间
  • delay – 是两次动画之间的间隔时间

注意:当小部件的父容器有指定宽度时,该小部件才可用。

GitHub

查看 Github