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

rich_readmore 封面
插件详情v1.1.1

rich_readmore

一个显示文本的控件,根据提供的设置可选择显示更多或更少。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
1070
喜欢数
45
Pub 分数
160

安装插件

flutter pub add rich_readmore

插件介绍

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

RichReadMore 是一个 Flutter 小部件,旨在以智能的“显示更多”或“显示更少”切换方式显示文本。它支持富文本格式,并根据内容长度和用户偏好动态调整。非常适合以简洁、交互式的方式显示长篇文本片段,提升可读性,同时不会使界面过于拥挤。该小部件可自定义,并可在所有主要平台上运行,包括移动设备、网页和桌面端。

适合场景

  • 在应用中显示长篇内容
  • 通过可折叠文本提升用户体验
  • 显示带有可展开详细信息的描述
  • 将富文本与交互式控件集成
  • 减少列表项中的屏幕杂乱

主要特点

  • 支持富文本格式
  • 动态显示更多/更少切换
  • 可自定义的省略号和按钮标签
  • 跨平台兼容性
  • 通过 pub 实现轻松集成
  • 可配置的行数限制

适合对象

  • 内容密集型应用
  • 具有可变文本长度的用户界面
  • 需要响应式文本显示的应用程序
  • 寻求轻量级文本扩展的开发者
  • 跨平台保持一致用户体验的项目

使用建议

  • 可能需要仔细调整样式以适应复杂布局
  • 使用超大文本时的性能影响
  • 仅限纯文本内容(无图片)
  • 依赖于父控件的约束
  • 不适用于非文本内容

原始 README

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

rich_readmore workflow codecov MIT License

rich_readmore

A widget that displays text with an option to show more or show less based on the provided settings.
The RichReadMoreText widget allows you to trim text either based on the character length or the number of lines.
When the text is longer than the specified trim length or exceeds the maximum number of lines, it provides a toggle option to show more or show less of the text.
It has two options for settings, the LineModeSettings or LengthModeSettings for trimming using the behavior that you want.
If you want to pass a string directly instead of a TextSpan, you can just be using the the RichReadMoreText.fromString(...). There are some examples for that below.

Demonstration

How to use

import:

import 'package:rich_readmore/rich_readmore.dart';

For TextSpan data:

 RichReadMoreText(
   textSpan,
   settings: LineModeSettings(
     trimLines: 3,
     trimCollapsedText: 'Expand',
     trimExpandedText: ' Collapse ',
     onPressReadMore: () {
       /// specific method to be called on press to show more
     },
     onPressReadLess: () {
       /// specific method to be called on press to show less
     },
   ),
 ),

Or for String data:

 RichReadMoreText.fromString(
   text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
   textStyle: TextStyle(color: Colors.purpleAccent),
   settings: LengthModeSettings(
     trimLength: 20,
     trimCollapsedText: 'Expand',
     trimExpandedText: ' Collapse ',
     onPressReadMore: () {
       /// specific method to be called on press to show more
     },
     onPressReadLess: () {
       /// specific method to be called on press to show less
     },
     lessStyle: TextStyle(color: Colors.blue),
     moreStyle: TextStyle(color: Colors.blue),
   ),
 ),

所属分类

源码仓库

使用此插件的项目

暂无相关数据。