FLUTTER ECOSYSTEM

thierryoliveira/rich_readmore

동적으로 풍부한 텍스트를 확장하고 축소할 수 있는 Flutter 플러그인

rich_readmore 프로젝트 이미지
Stars
7
Forks
7
최근 푸시(UTC)
2023. 12. 7.
프로젝트 상태
활성
Thierry Oliveira GitHub avatar
GITHUB User

Thierry Oliveira ↗

Mobile Engineer

VeryGoodVenturesJales, São Paulo, Brasil
언어DartSwiftKotlinObjective-C

이 저장소가 배포한 패키지

사용 중인 의존성

의존성 목록 2 개
  • flutter{"sdk":"flutter"}
  • flutter_test개발 의존성{"sdk":"flutter"}

원본 README

아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.

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

https://raw.githubusercontent.com/thierryoliveira/rich_readmore/HEAD/read-more-text-view-flutter.gif

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),
   ),
 ),