Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dutchcodingcompany/read_more_less
A package that shows a read more/less button based on if the text overflows
https://github.com/dutchcodingcompany/read_more_less
Last synced: about 1 month ago
JSON representation
A package that shows a read more/less button based on if the text overflows
- Host: GitHub
- URL: https://github.com/dutchcodingcompany/read_more_less
- Owner: DutchCodingCompany
- License: mit
- Created: 2022-05-02T11:23:15.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-08-16T10:14:31.000Z (4 months ago)
- Last Synced: 2024-08-23T06:02:16.784Z (4 months ago)
- Language: Dart
- Size: 4.29 MB
- Stars: 3
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# read_more_less
Provides a widget that shows a read more/less button in case the text exceeds the `maxHeight` provided in the widget.
## Getting Started
### Basic usage
The basic usage is simple. You provide a text and the widget will decide based on the maxHeight if it should show a read more/less button or not.
It is possible to edit the maxHeight (default is 70) as a parameter of `ReadMoreLess`.```dart
ReadMoreLess(
text: '''
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur et lobortis erat. Sed vulputate elit lacinia justo tincidunt varius. Nam convallis semper magna, a volutpat turpis feugiat sed. Morbi ac ligula suscipit, lobortis arcu at, ornare justo. Maecenas vestibulum, eros et imperdiet egestas, tellus enim porttitor risus, sit amet tincidunt est neque nec arcu. Pellentesque egestas dolor vitae nisl varius, ut hendrerit nisl auctor. Morbi eget ex sapien. Donec congue sagittis ante, ac fermentum felis molestie at. Integer pharetra nec est at blandit. Nullam vestibulum at est id sollicitudin. Etiam maximus ipsum orci, nec placerat ligula pharetra vel. Curabitur rutrum justo et mauris eleifend, in tristique dolor molestie. Nullam ut sem quis orci dictum vestibulum eu ac sem. Nam eu consectetur lacus. Nulla ut elit sed urna condimentum efficitur.
''',
),
```## Screenshots
Example gif:
![Example](assets/example.gif)## Parameters
| Parameter | Type | Description |
| ----------------- | ---------- | ----------------------------------------------------------------------------------------------------------------------- |
| text | String | The main text to be displayed. |
| readLessText | String? | The text on the button when the text is expanded, in case the text overflows |
| readMoreText | String? | The text on the button when the text is collapsed, in case the text overflows |
| animationDuration | Duration | The duration of the animation when transitioning between read more and read less. |
| maxHeight | double | The maximum height of container around the [text] in the collapsed state. |
| textStyle | TextStyle? | The main textstyle used for [text] |
| textAlign | TextAlign | Whether and how to align [text] horizontally. |
| iconCollapsed | Widget | Allows a widget to replace the icon in the read more/less button in the collapsed state. |
| iconExpanded | Widget | Allows a widget to replace the icon in the read more/less button in the expanded state. |
| iconColor | Color | The color of the icon in the read more/less button. Does not work when [iconCollapsed] or [iconExpanded] are specified. |
| buttonTextStyle | TextStyle | The textstyle used for the read more/less button |