All Projects → 2000calories → Flutter_easy_rich_text

2000calories / Flutter_easy_rich_text

Licence: mit
The EasyRichText widget provides an easy way to use RichText.

Programming Languages

dart
5743 projects

Projects that are alternatives of or similar to Flutter easy rich text

Regexp2
A full-featured regex engine in pure Go based on the .NET engine
Stars: ✭ 389 (+1196.67%)
Mutual labels:  regular-expression
Go Restructure
Match regular expressions into struct fields
Stars: ✭ 570 (+1800%)
Mutual labels:  regular-expression
R4ds
📖 R for data import/export , clean, wrangling, exploration, visualization, & analysis with R https://xiangyunhuang.github.io/r4ds/
Stars: ✭ 19 (-36.67%)
Mutual labels:  regular-expression
Stringr
A fresh approach to string manipulation in R
Stars: ✭ 397 (+1223.33%)
Mutual labels:  regular-expression
Regulex
🚧 Regular Expression Excited!
Stars: ✭ 4,877 (+16156.67%)
Mutual labels:  regular-expression
Cyberchef Recipes
A list of cyber-chef recipes and curated links
Stars: ✭ 619 (+1963.33%)
Mutual labels:  regular-expression
Minta
✳️  Electron app for generating regular expressions
Stars: ✭ 353 (+1076.67%)
Mutual labels:  regular-expression
Regex
A sane interface for php's built in preg_* functions
Stars: ✭ 909 (+2930%)
Mutual labels:  regular-expression
Onigmo
Onigmo is a regular expressions library forked from Oniguruma.
Stars: ✭ 536 (+1686.67%)
Mutual labels:  regular-expression
Libphorward
C/C++ library for dynamic data structures, regular expressions, lexical analysis & more...
Stars: ✭ 18 (-40%)
Mutual labels:  regular-expression
Hae
HaE - BurpSuite Highlighter and Extractor
Stars: ✭ 397 (+1223.33%)
Mutual labels:  regular-expression
Chinamobilephonenumberregex
Regular expressions that match the mobile phone number in mainland China. / 一组匹配中国大陆手机号码的正则表达式。
Stars: ✭ 4,440 (+14700%)
Mutual labels:  regular-expression
Guitar
A Cross-Platform String and Regular Expression Library written in Swift.
Stars: ✭ 641 (+2036.67%)
Mutual labels:  regular-expression
Picomatch
Blazing fast and accurate glob matcher written JavaScript, with no dependencies and full support for standard and extended Bash glob features, including braces, extglobs, POSIX brackets, and regular expressions.
Stars: ✭ 393 (+1210%)
Mutual labels:  regular-expression
Shallow Clone
Make a shallow clone of an object, array or primitive.
Stars: ✭ 23 (-23.33%)
Mutual labels:  regular-expression
Subconverter
Utility to convert between various subscription format
Stars: ✭ 4,912 (+16273.33%)
Mutual labels:  regular-expression
Debugviewpp
DebugView++, collects, views, filters your application logs, and highlights information that is important to you!
Stars: ✭ 592 (+1873.33%)
Mutual labels:  regular-expression
Regexanalyzer
Regular Expression Analyzer and Composer for Node.js / XPCOM / Browser Javascript, PHP, Python
Stars: ✭ 29 (-3.33%)
Mutual labels:  regular-expression
Whitespace Regex
Regular expression for matching the whitespace in a string.
Stars: ✭ 9 (-70%)
Mutual labels:  regular-expression
Commonregex
🍫 A collection of common regular expressions for Go
Stars: ✭ 733 (+2343.33%)
Mutual labels:  regular-expression

easy_rich_text

pub package GitHub license GitHub stars

The EasyRichText widget makes the RichText widget easy. You do not have to split the string manually.

This widget use regular expression to effectively split the string based on the patterns defined in the list of EasyRichTextPattern.

The EasyRichTextPattern is a class defines the text pattern you want to format. By default matchWordBoundaries:true is set to match the whole word. If you want to match substring in a word, set matchWordBoundaries:false

GestureRecognizer and url_launcher are integrated.

Getting Started

Installing:

dependencies:
  easy_rich_text: '^0.5.4'

Examples:

Simple Example | Trademark Example | Default Style | Conditional Match | Match Option | Superscript and Subscript | Case Sensitivity | Selectable Text | Regular Expression | Url Launcher | GestureRecognizer | All RichText Properties | Special Characters

Simple Example:

alt text

EasyRichText(
  "I want blue font. I want bold font. I want italic font.",
  patternList: [
    EasyRichTextPattern(
      targetString: 'blue',
      style: TextStyle(color: Colors.blue),
    ),
    EasyRichTextPattern(
      targetString: 'bold',
      style: TextStyle(fontWeight: FontWeight.bold),
    ),
    EasyRichTextPattern(
      targetString: 'italic',
      style: TextStyle(fontStyle: FontStyle.italic),
    ),
  ],
),

Trademark Example

alt text

EasyRichText(
  "ProductTM is a superscript trademark symbol. This TM is not a trademark.",
  patternList: [
    EasyRichTextPattern(
      targetString: 'TM',
      superScript: true,
      stringBeforeTarget: 'Product',
      matchWordBoundaries: false,
      style: TextStyle(color: Colors.blue),
    ),
  ],
),

Default Style:

alt text

EasyRichText(
  "This is a EasyRichText example with default grey font. I want blue font here.",
  defaultStyle: TextStyle(color: Colors.grey),
  patternList: [
    EasyRichTextPattern(
      targetString: 'blue',
      style: TextStyle(color: Colors.blue),
    ),
    EasyRichTextPattern(
      targetString: 'bold',
      style: TextStyle(fontWeight: FontWeight.bold),
    ),
  ],
),

Conditional Match

alt text

EasyRichText(
  "I want blue color here. I want no blue font here. I want blue invalid here.",
  patternList: [
    EasyRichTextPattern(
      targetString: 'blue',
      stringBeforeTarget: 'want',
      stringAfterTarget: "color",
      style: TextStyle(color: Colors.blue),
    ),
  ],
),

Match Option

alt text

matchOption can be a string or a list. default is 'all'.
string: 'all', 'first', 'last'
List:'first', 'last', and any integer index
For example, [0, 1, 'last'] will match the first, second, and last one.
EasyRichText(
  "blue 1, blue 2, blue 3, blue 4, blue 5",
  patternList: [
    EasyRichTextPattern(
      targetString: 'blue',
      //matchOption: 'all'
      matchOption: [0, 1, 'last'],
      style: TextStyle(color: Colors.blue),
    ),
  ],
),

Superscript and Subscript.

alt text

EasyRichText(
  "I want superscript font here. I want subscript here",
  patternList: [
    EasyRichTextPattern(
        targetString: 'superscript', superScript: true),
    EasyRichTextPattern(
        targetString: 'subscript', subScript: true),
  ],
),

Case Sensitivity

alt text

EasyRichText(
  "Case-Insensitive String Matching. I want both Blue and blue. This paragraph is selectable.",
  caseSensitive: false,
  selectable: true,
  patternList: [
    EasyRichTextPattern(
      targetString: 'Blue',
      style: TextStyle(color: Colors.blue),
    ),
  ],
),

Selectable Text

alt text

EasyRichText(
  "This paragraph is selectable...",
  selectable: true,
),

Regular Expression

alt text

EasyRichText(
  "Regular Expression. I want blue bluea blue1 but not blueA",
  patternList: [
    EasyRichTextPattern(
      targetString: 'bl[a-z0-9]*',
      style: TextStyle(color: Colors.blue),
    ),
  ],
),

Url Launcher

Integrated with url_launcher. Web url, email url, and telephone url are supported. Set urlType : 'web', 'email', or 'tel'. EasyRichText provides regular expression formula to match common urls.

alt text

EasyRichText(
  "Here is a website https://pub.dev/packages/easy_rich_text. Here is a email address [email protected] Here is a telephone number +852 12345678.",
  patternList: [
    EasyRichTextPattern(
      targetString: 'https://pub.dev/packages/easy_rich_text',
      urlType: 'web',
      style: TextStyle(
        decoration: TextDecoration.underline,
      ),
    ),
    EasyRichTextPattern(
      targetString: EasyRegexPattern.emailPattern,
      urlType: 'email',
      style: TextStyle(
        decoration: TextDecoration.underline,
      ),
    ),
    EasyRichTextPattern(
      targetString: EasyRegexPattern.webPattern,
      urlType: 'web',
      style: TextStyle(
        decoration: TextDecoration.underline,
      ),
    ),
    EasyRichTextPattern(
      targetString: EasyRegexPattern.telPattern,
      urlType: 'tel',
      style: TextStyle(
        decoration: TextDecoration.underline,
      ),
    ),
  ],
),

GestureRecognizer

///GestureRecognizer, not working when superscript, subscript, or urlType is set.
///TapGestureRecognizer, MultiTapGestureRecognizer, etc.
EasyRichText(
  "Tap recognizer to print this sentence.",
  patternList: [
    EasyRichTextPattern(
      targetString: 'recognizer',
      recognizer: TapGestureRecognizer()
        ..onTap = () {
          print("Tap recognizer to print this sentence.");
        },
      style: TextStyle(
        decoration: TextDecoration.underline,
      ),
    ),
  ],
),

All RichText Properties

alt text

EasyRichText(
  "TextOverflow.ellipsis, TextAlign.justify, maxLines: 1. TextOverflow.ellipsis, TextAlign.justify, maxLines: 1.",
  textAlign: TextAlign.justify,
  maxLines: 1,
  overflow: TextOverflow.ellipsis,
),

Special Characters

alt text

//if the targetString contains the following special characters \[]()^*+?
EasyRichText(
  "Received 88+ messages. Received 99+ messages",
  patternList: [
    //set hasSpecialCharacters to true
    EasyRichTextPattern(
      targetString: '99+',
      hasSpecialCharacters: true,
      style: TextStyle(color: Colors.blue),
    ),
    //or if you are familiar with regular expressions, then use \\ to skip it
    EasyRichTextPattern(
      targetString: '88\\+',
      style: TextStyle(color: Colors.blue),
    ),
  ],
),

Known issues

Conflict when one target string is included in another target string

alt text

EasyRichText(
  "This is a EasyRichText example. I want whole sentence blue. I want whole sentence bold.",
  patternList: [
    EasyRichTextPattern(
      targetString: 'I want whole sentence blue',
      style: TextStyle(fontWeight: FontWeight.bold),
    ),
    EasyRichTextPattern(
      targetString: 'blue',
      style: TextStyle(color: Colors.blue),
    ),
    EasyRichTextPattern(
      targetString: 'I want whole sentence bold',
      style: TextStyle(fontWeight: FontWeight.bold),
    ),
  ],
),

If you find EasyRichText makes RichText easy, I would appreciate it if you can give me a star on Github and a like on pub.dev

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].