2000calories / flutter_easy_rich_text

The EasyRichText widget provides an easy way to use RichText.
https://pub.dev/packages/easy_rich_text
MIT License
80 stars 33 forks source link

When we us special characters in EasyRichText as Target String like ~|[]{}#%^*+=_|<>$£€•.,?!’ it crashes & fires exception. #7

Closed nirajjoshi closed 4 years ago

nirajjoshi commented 4 years ago

@2000calories :

When we us special characters in EasyRichText as Target String like *~|[]{}#%^+=_|<>$£€•.,?!’** it crashes & fires below mentioned exception. Please refer screenshot from your example app only.

///GestureRecognizer, not working when superscript, subscript, or urlType is set.
              ///TapGestureRecognizer, MultiTapGestureRecognizer, etc.
              EasyRichText(
                "Tap recognizer to print this sentence.~|[]{}#%^*+=_\|<>\$£€•.,?!’",
                patternList: [
                  EasyRichTextPattern(
                    targetString: '~|[]{}#%^*+=_\|<>\$£€•.,?!’',
                    recognizer: TapGestureRecognizer()
                      ..onTap = () {
                        print("Tap recognizer to print this sentence.");
                      },
                    style: TextStyle(
                      decoration: TextDecoration.underline,
                    ),
                  ),
                ],
              ),

════════ Exception caught by widgets library ═══════════════════════════════════ The following FormatException was thrown building EasyRichText(dirty, dependencies: [DefaultTextStyle]): Lone quantifier *brackets((?<!\w)~|[]{}#%^+=_|<>$£€•.,?!’(?!\w))**

Screenshot 2020-10-08 at 3 29 20 PM
2000calories commented 4 years ago

try master branch and set hasSpecialCharacters: true

EasyRichText(
  "Tap recognizer to print this sentence. ~|[]{}#%^*+=_\|<>\$£€•.,?!’",
  patternList: [
    EasyRichTextPattern(
      targetString: '~|[]{}#%^*+=_|<>\$£€•.,?',
      hasSpecialCharacters: true,
      recognizer: TapGestureRecognizer()
        ..onTap = () {
          print("Tap recognizer to print this sentence.");
        },
      style: TextStyle(
        decoration: TextDecoration.underline,
      ),
    ),
  ],
),
  easy_rich_text:
    git:
      url: https://github.com/2000calories/flutter_easy_rich_text.git
      ref: master
nirajjoshi commented 4 years ago

try master branch and set hasSpecialCharacters: true

EasyRichText(
  "Tap recognizer to print this sentence. ~|[]{}#%^*+=_\|<>\$£€•.,?!’",
  patternList: [
    EasyRichTextPattern(
      targetString: '~|[]{}#%^*+=_|<>\$£€•.,?',
      hasSpecialCharacters: true,
      recognizer: TapGestureRecognizer()
        ..onTap = () {
          print("Tap recognizer to print this sentence.");
        },
      style: TextStyle(
        decoration: TextDecoration.underline,
      ),
    ),
  ],
),
  easy_rich_text:
    git:
      url: https://github.com/2000calories/flutter_easy_rich_text.git
      ref: master

Thanks @2000calories . It worked. Please update pub version with this fix at https://pub.dev/packages/easy_rich_text as well.

2000calories commented 4 years ago

updated

nirajjoshi commented 4 years ago

updated

Thanks.