Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FormatException: Range out of order in character class #40

Closed
Alexander-TM opened this issue Dec 31, 2022 · 6 comments
Closed

FormatException: Range out of order in character class #40

Alexander-TM opened this issue Dec 31, 2022 · 6 comments
Labels
special character special character like \[]()^*+?

Comments

@Alexander-TM
Copy link

Flutter throwing this exception:

The following FormatException was thrown building EasyRichText(dirty):
Range out of order in character class((?<!\w)qu'y a-t-il? [ou qu'est-ce qu'il y a?] ― il y a que j'ai faim!(?!\w))
@2000calories
Copy link
Owner

Please show your flutter doctor output.

@Alexander-TM
Copy link
Author

I'm using VS Code and testing on android device.

[✓] Flutter (Channel stable, 3.3.10, on Mac OS X 10.15.7 19H2026 darwin-x64, locale en-CA)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[!] Xcode - develop for iOS and macOS (Xcode 12.4)
✗ Flutter requires Xcode 13 or higher.
Download the latest version or update via the Mac App Store.
! CocoaPods 1.10.1 out of date (1.11.0 is recommended).
CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/platform-plugins
To upgrade see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] IntelliJ IDEA Community Edition (version 2022.1.2)
[✓] VS Code (version 1.74.2)
[✓] Connected device (3 available)
[✓] HTTP Host Availability

@2000calories
Copy link
Owner

I do not see any error after upgrading to 3.3.10. Please show your widget code.

@Alexander-TM
Copy link
Author

Alexander-TM commented Jan 15, 2023

The code:

Flexible(
              child: EasyRichText(
                trans.source + ": " + trans.targetObj.text!,
                patternList: [
                  EasyRichTextPattern(
                      targetString: trans.source,
                      style: const TextStyle(
                        fontStyle: FontStyle.italic, fontSize: 15,
                        // color: Colors.grey.shade700
                      )),
                  EasyRichTextPattern(
                      targetString: trans.targetObj.text,
                      style: TextStyle(
                          fontWeight: FontWeight.bold,
                          fontSize: 15,
                          // backgroundColor: globals.genderColors[trans.targetObj.gender]
                          color: globals.genderColors[trans.targetObj.gender]))
                ],
              ),
            ),

===============================================================

It works perfectly until it stumbles upon this following text in french and english, is there a character that's causing this exception? is it the bracket ']' character in the middle of part1? I think the bracket confuses the widget into processing it as part of a regex? does it make sense?

==================================================================

Part 1: "qu'y a-t-il? ou qu'est-ce qu'il y a?] ― il y a que j'ai faim!",
Part 2: "what's the matter? ― I'm hungry, that's what!"

@2000calories
Copy link
Owner

EasyRichTextPattern(
  targetString: trans.source,
  //set hasSpecialCharacters
  hasSpecialCharacters: true,
  style: const TextStyle(
    fontStyle: FontStyle.italic, fontSize: 15,
    // color: Colors.grey.shade700
)),

@Alexander-TM
Copy link
Author

It worked thank you

@2000calories 2000calories added the special character special character like \[]()^*+? label Jan 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
special character special character like \[]()^*+?
Projects
None yet
Development

No branches or pull requests

2 participants