parsed_readmore 0.0.6 copy "parsed_readmore: ^0.0.6" to clipboard
parsed_readmore: ^0.0.6 copied to clipboard

A Flutter text widget which is expandable and can automatically parse urls present in the text it into clickable links.

Parsed Readmore #

A package which allows to enter text which can be collapsed and expanded. Moreover, it will automatically parse the urls present in the text into hyperlinks.

Demo Gif

Features #

  • Expandable and Collapsable text.
  • Trimming can either be done on basis of length or number of lines.
  • Option to include a customised delimiter.
  • Automatically parses the urls present in the text into hyperlinks which launches the browser on click event.
  • All the text components including the parsed urls, delimiter, clickable texts, etc can be given seperate custom styles.
  • Addition of user defined action on clicking the hyperlinks (latest addition).
  • Option to add custom text styles for target text (latest addition).

Installation #

Run this command in your terminal

flutter pub add parsed_readmore

Or add it manually in your project's pubspec.yaml (and run an implicit flutter pub get):

dependencies:
  parsed_readmore: 

Usage Example #

For detailed implementation refer to the example #

Import parsed_readmore.dart

import 'package:parsed_readmore/parsed_readmore.dart';

The code below will implement all features of the widget with the default values which are :

  • trimMode = TrimMode.length
  • delimiter = ' ...'
  • trimLength = 240
  • trimExpandedText = 'show less',
  • trimCollapsedText = 'read more',
ParsedReadMore(inputString)

If you need to use some customized values for different elements of the widget just add values to the relevant parameters.

ParsedReadMore(
    inputString,
    urlTextStyle: TextStyle(color: Colors.green, fontSize: 20, decoration: TextDecoration.underline),
    trimMode: TrimMode.line,
    trimLines: 4,
    delimiter: '  ***',
    delimiterStyle: TextStyle(color: Colors.black, fontSize: 20),
    style: TextStyle(color: Colors.orange, fontSize: 20),
    onTapLink: (url) {
      ScaffoldMessenger.of(context).showSnackBar(SnackBar(
          content: Text(
              '$url is displayed because we have used custom onTap function for hyperlinks')));
    },
    highlightText: TargetTextHighlight(
        targetText: 'the',
        style: const TextStyle(
            fontSize: 20.0,
            fontStyle: FontStyle.italic,
            color: Colors.purple)),
    trimCollapsedText: 'expand',
    trimExpandedText: 'compress',
    moreStyle: TextStyle(color: Colors.red, fontSize: 20),
    lessStyle: TextStyle(color: Colors.blue, fontSize: 20),
)

Issues #

Please file any issues, bugs or feature request as an issue on the GitHub page. If you have some idea for feature upgrade, feel free to contact me through email aashish.260401@gmail.com.

32
likes
0
pub points
83%
popularity

Publisher

unverified uploader

A Flutter text widget which is expandable and can automatically parse urls present in the text it into clickable links.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, url_launcher

More

Packages that depend on parsed_readmore