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

[BUG] Feature tag must be exactly four characters long. #1362

Open
LorisTrainect opened this issue Aug 21, 2023 · 14 comments
Open

[BUG] Feature tag must be exactly four characters long. #1362

LorisTrainect opened this issue Aug 21, 2023 · 14 comments
Labels
bug Something isn't working

Comments

@LorisTrainect
Copy link

LorisTrainect commented Aug 21, 2023

Describe the bug:

Feature tag must be exactly four characters long.
'dart:ui/text.dart':
Failed assertion: line 143 pos 14: ''

HTML to reproduce the issue:

I get my html code from a database, when is present inline css property 'font-feature-settings' i got this bug

Html widget configuration:

Here my use of Html widget:

SingleChildScrollView(
    padding: const EdgeInsets.only(bottom: 50,top: 0),
    child: Padding(
      padding: const EdgeInsets.symmetric(horizontal: 20),
      child: Html(
        data: post.html,
        style: {
          "br": Style(
            display: Display.none,
          ),
          "p": Style(
            margin: Margins.symmetric(vertical: 20),
            fontSize: FontSize.large
          ),
          "h1": Style(
            fontWeight: FontWeight.bold,
            fontSize: FontSize.xxLarge
          ),
          "b": Style(
            fontWeight: FontWeight.bold,
            fontSize: FontSize.xLarge
          )
        },
      ),
    ),
  ),

Device details and Flutter/Dart/flutter_html versions:

flutter_html version 3.0.0-beta.2
flutter version:
Flutter 3.10.6 • channel stable • https://github.com/flutter/flutter.git
Framework • revision f468f3366c (6 weeks ago) • 2023-07-12 15:19:05 -0700
Engine • revision cdbeda788a
Tools • Dart 3.0.6 • DevTools 2.23.1

Stacktrace/Logcat

The relevant error-causing widget was:
Html Html:file:///C:/Users/nickn/Documents/FlutterProjects/MyTrainect/lib/Views/post_view.dart:148:30
When the exception was thrown, this was the stack:
#2 new FontFeature (dart:ui/text.dart:143:14)
#3 new FontFeature.enable (dart:ui/text.dart:147:46)
#4 ExpressionMapping.expressionToFontFeatureSettings (package:flutter_html/src/css_parser.dart:948:42)
#5 declarationsToStyle. (package:flutter_html/src/css_parser.dart:318:33)
#6 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:625:13)
#7 declarationsToStyle (package:flutter_html/src/css_parser.dart:13:16)
#8 inlineCssToStyle (package:flutter_html/src/css_parser.dart:671:12)
#9 _HtmlParserState._styleTreeRecursive (package:flutter_html/src/html_parser.dart:309:11)
#10 _HtmlParserState._styleTreeRecursive (package:flutter_html/src/html_parser.dart:325:7)
#11 _HtmlParserState._styleTreeRecursive (package:flutter_html/src/html_parser.dart:325:7)
#12 _HtmlParserState.styleTree (package:flutter_html/src/html_parser.dart:294:5)
#13 _HtmlParserState.prepareTree (package:flutter_html/src/html_parser.dart:166:5)
#14 _HtmlParserState.didChangeDependencies (package:flutter_html/src/html_parser.dart:156:5)
#15 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:5237:11)
#16 ComponentElement.mount (package:flutter/src/widgets/framework.dart:5062:5)

@LorisTrainect LorisTrainect added the bug Something isn't working label Aug 21, 2023
@hakama99
Copy link

hakama99 commented Sep 2, 2023

same question

@LorisTrainect
Copy link
Author

Trying a build apk release, this error seems not to be present, however I still get it in the debug version

@JulioRennan
Copy link

JulioRennan commented Sep 14, 2023

Same question, someone had an update about this?

@hugofpaiva
Copy link

I'm having the same issue on a project i'm working on... :/

@TheHKF
Copy link

TheHKF commented Sep 19, 2023

same question,

@huyhb
Copy link

huyhb commented Sep 29, 2023

I have same issue? Please let me know if anyone has a solution!

@ElixirMike
Copy link

same...need solution

@okarasahin
Copy link

I have same issue too. Any solution?

@smujaddid
Copy link

I have same issue with no solution

@alihan-ulker
Copy link

Hello, I had the same problem with the flutter_html version 3.0.0-beta.2 package.
I was getting the same error when I wanted to load the html information coming in the form of Html(data: htmlContent)). Then I realized that it was caused by special characters.
setState((() {
htmlContent = data!.newContent!;
cleanedHtmlContent = htmlContent.replaceAll(RegExp(r'<[^>]*>'), ''');
});
When I tried by cleaning the special characters in it, my Html(data: cleanedHtmlContent) page opened without any problems. Maybe it will help you. Good coding :D

@okarasahin
Copy link

I solved the problem by using a different package. For those interested : flutter_widget_from_html_core
Happy codings! :D

@taskindrp
Copy link

Hello, I had the same problem with the flutter_html version 3.0.0-beta.2 package. I was getting the same error when I wanted to load the html information coming in the form of Html(data: htmlContent)). Then I realized that it was caused by special characters. setState((() { htmlContent = data!.newContent!; cleanedHtmlContent = htmlContent.replaceAll(RegExp(r'<[^>]*>'), '''); }); When I tried by cleaning the special characters in it, my Html(data: cleanedHtmlContent) page opened without any problems. Maybe it will help you. Good coding :D

regex you used just removes all the tags, which defeats the purpose.

@koreaksh
Copy link

koreaksh commented Apr 29, 2024

"I also encountered the same issue, and as a solution, I used the provided code."

data.replaceAll('font-feature-settings: normal;', '');

"If this method doesn't work, try finding the 'feature' part in the HTML data and remove it using the same approach."

@yalda-student
Copy link

data.replaceAll('font-feature-settings: normal;', '');

Thank u. It works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Todo
Development

No branches or pull requests