extended_markdown_viewer 0.1.0
extended_markdown_viewer: ^0.1.0 copied to clipboard
A Flutter package that displays markdown text in a flutter widget with support for simple html tags like <u>, <b> and <i>,<li><ol><ul> etc , while also allowing you to expand or collapse the widget
Extended Markdown Viewer #
A Flutter package that provides a customizable Markdown viewer with "Read More/Less" functionality, perfect for displaying collapsible Markdown content in your Flutter applications.
Features #
- π Renders Markdown content with HTML support
- βοΈ Expandable/Collapsible text with smooth animation
- π¨ Customizable appearance including text colors and read more/less widgets
- π Customizable link tap handling
- π Configurable collapsed text length
- π― Smart text truncation that preserves HTML structure
Getting started #
Add this package to your Flutter project by including it in your pubspec.yaml:
dependencies:
extended_markdown_viewer: ^1.0.0
Usage #
Here's a simple example of how to use ExtendedMarkDownViewer:
ExtendedMarkDownViewer(
markdownText: '''
# Hello World
This is a markdown text that can be collapsed and expanded.
It supports **bold**, *italic*, and [links](https://example.com).
''',
maxCollapsedLength: 100,
readMoreText: 'Show more',
readLessText: 'Show less',
)
Customization #
You can customize various aspects of the viewer:
ExtendedMarkDownViewer(
markdownText: yourMarkdownText,
maxCollapsedLength: 150,
readMoreText: 'Continue reading',
readLessText: 'Close',
expandedTextColor: Colors.black,
collapsedTextColor: Colors.grey,
readMoreTextColor: Colors.blue,
readLessTextColor: Colors.blue,
readMoreWidget: CustomWidget(), // Custom widget for read more button
readLessWidget: CustomWidget(), // Custom widget for read less button
onLinkTap: (url, context, params) {
// Handle link taps
},
)
Additional information #
Properties #
markdownText: The Markdown content to displaymaxCollapsedLength: Maximum length of text when collapsed (default: 80)readMoreText: Text for expand button (default: "Read more")readLessText: Text for collapse button (default: "Read less")expandedTextColor: Color of text when expandedcollapsedTextColor: Color of text when collapsedreadMoreTextColor: Color of read more textreadLessTextColor: Color of read less textonLinkTap: Callback for handling link taps
Contributing #
Contributions are welcome! Please feel free to submit a Pull Request.
License #
This project is licensed under the MIT License - see the LICENSE file for details.