Coder Social home page Coder Social logo

mobisofts / read_morex Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tro1d/read_morex

0.0 0.0 0.0 412 KB

A Flutter package for display text with the option to expand, collapse it and also apply custom text filters to highlight or modify specific patterns within the text.

License: MIT License

Objective-C 0.21% Kotlin 0.76% Dart 95.13% Swift 3.89%

read_morex's Introduction

Read MoreX pub package

The read_morex package is a Flutter widget that allows you to manage the display of long text with a "Read More" button that lets users expand to view the entire text or collapse it to a shorter version. It allows you to set a maximum number of lines and a maximum length for the text. When the content exceeds these limits, it provides a 'Read more' link, allowing users to see the full content, and a 'Show less' link to collapse it again. You can also apply custom text filters using regular expressions to highlight or modify specific patterns within the text. This widget offers flexibility and control over how text content is displayed and filtered within your Flutter app.

Example Screenshot

Installation

You can import the read_morex package into your Flutter project by adding the following dependency to your pubspec.yaml file:

dependencies:
  read_morex: ^1.1.0

Don't forget to run flutter pub get after adding this dependency.

Usage

Here's how to use it:

Import the read_morex package:

import 'package:read_morex/read_morex.dart';

Use the ReadMoreX widget in your layout:

Read More

ReadMoreX(
    'This is a very long text. You can tap the "Read More" button to see more text. Suspendisse interdum consectetur libero id faucibus nisl tincidunt eget nullam. Eu nisl nunc mi ipsum faucibus vitae aliquet nec.',
    textStyle: const TextStyle(fontSize: 18),
    readMoreColor: Colors.green,
    fontWeightLabel: FontWeight.normal,
),

Read More with Filter

ReadMoreX(
    'Link: https://github.com/tro1d\nAlternative link: https://flutter.dev\nEmail: [email protected]\nPhone: 0808080889',
    textStyle: const TextStyle(fontSize: 18),
    readMoreColor: Colors.green,
    filterContent: true,
    fontWeightLabel: FontWeight.normal,
    customFilter: <ReadMoreXPattern>[
        ReadMoreXPattern(
            pattern: r'github.com', // Sensitive https://
            valueChanged: (value) => value?.replaceFirst('https://github.com/', 'Github '),
            onTap: (value) {
                ScaffoldMessenger.of(context).showSnackBar(
                SnackBar(content: Text('This Link $value')),
                );
            },
        ),
        ReadMoreXPattern(
            pattern: r'https://', // Sensitive https:// , after github.com
            onTap: (value) {
                ScaffoldMessenger.of(context).showSnackBar(
                SnackBar(content: Text('This Link $value')),
                );
            },
        ),
        ReadMoreXPattern(
            pattern: r'\b[0-9]{9,}\b',
            colorChanged: Colors.red,
            onTap: (value) {
                ScaffoldMessenger.of(context).showSnackBar(
                SnackBar(content: Text('This Number $value')),
                );
            },
        ),
        ReadMoreXPattern(
            pattern: r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b',
            colorChanged: Colors.deepPurple,
            onTap: (value) {
                ScaffoldMessenger.of(context).showSnackBar(
                SnackBar(content: Text('This Email $value')),
                );
            },
        ),
    ],
),

Full example can be found at example/lib/main.dart.

read_morex's People

Contributors

tro1d avatar mobisofts avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.