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

Style attribute 'before tag creates exception and after not working #650

Closed
DFelten opened this issue May 1, 2021 · 3 comments · Fixed by #653
Closed

Style attribute 'before tag creates exception and after not working #650

DFelten opened this issue May 1, 2021 · 3 comments · Fixed by #653

Comments

@DFelten
Copy link
Contributor

DFelten commented May 1, 2021

Currently it seems that the before and after attribute of the custom styles is not working as expected.

When using after, nothing changes and the after text is not appearing:

image

const String test = '<p class="test">This is a test with before and after tag.</p>';

return Html(
  data: test,
  style: {
    '.test': Style(
      after: 'TEXT',
    ),
  },
);

When using before an exception appears

const String test = '<p class="test">This is a test with before and after tag</p>';

return Html(
  data: test,
  style: {
    '.test': Style(
      before: 'test',
    ),
  },
);

image

The full exception:
flutter: ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
flutter: The following StackOverflowError was thrown building HtmlParser(dirty, dependencies:
flutter: [_InheritedTheme, _LocalizationsScope-[GlobalKey#b3a97], MediaQuery]):
flutter: Stack Overflow
flutter:
flutter: The relevant error-causing widget was:
flutter:   Html
flutter:   file:///Users/daniel/Projekte/TMX/China-Gadgets/tmx_framework/packages/core/lib/src/features/html/widgets/tmx_html.dart:44:12
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0      new Object (dart:core/object.dart:24:3)
flutter: #1      new StyledElement (package:flutter_html/src/styled_element.dart)
flutter: #2      new ReplacedElement (package:flutter_html/src/replaced_element.dart:32:8)
flutter: #3      new TextContentElement (package:flutter_html/src/replaced_element.dart:55:8)
flutter: #4      HtmlParser._processBeforesAndAfters (package:flutter_html/html_parser.dart:551:14)
flutter: #5      List.forEach (dart:core-patch/growable_array.dart:403:8)
flutter: #6      HtmlParser._processBeforesAndAfters (package:flutter_html/html_parser.dart:557:21)
flutter: #7      List.forEach (dart:core-patch/growable_array.dart:403:8)
flutter: #8      HtmlParser._processBeforesAndAfters (package:flutter_html/html_parser.dart:557:21)
flutter: #9      List.forEach (dart:core-patch/growable_array.dart:403:8)
flutter: #10     HtmlParser._processBeforesAndAfters (package:flutter_html/html_parser.dart:557:21)
flutter: #11     List.forEach (dart:core-patch/growable_array.dart:403:8)
flutter: #12     HtmlParser._processBeforesAndAfters (package:flutter_html/html_parser.dart:557:21)
flutter: #13     List.forEach (dart:core-patch/growable_array.dart:403:8)
flutter: #14     HtmlParser._processBeforesAndAfters (package:flutter_html/html_parser.dart:557:21)
flutter: #15     List.forEach (dart:core-patch/growable_array.dart:403:8)
flutter: #16     HtmlParser._processBeforesAndAfters (package:flutter_html/html_parser.dart:557:21)
flutter: #17     List.forEach (dart:core-patch/growable_array.dart:403:8)
flutter: #18     HtmlParser._processBeforesAndAfters (package:flutter_html/html_parser.dart:557:21)
flutter: #19     List.forEach (dart:core-patch/growable_array.dart:403:8)
flutter: #20     HtmlParser._processBeforesAndAfters (package:flutter_html/html_parser.dart:557:21)
flutter: #21     List.forEach (dart:core-patch/growable_array.dart:403:8)
flutter: #22     HtmlParser._processBeforesAndAfters (package:flutter_html/html_parser.dart:557:21)
flutter: #23     List.forEach (dart:core-patch/growable_array.dart:403:8)
flutter: #24     HtmlParser._processBeforesAndAfters (package:flutter_html/html_parser.dart:557:21)
flutter: #25     List.forEach (dart:core-patch/growable_array.dart:403:8)
flutter: #26     HtmlParser._processBeforesAndAfters (package:flutter_html/html_parser.dart:557:21)
flutter: #27     List.forEach (dart:core-patch/growable_array.dart:403:8)
flutter: #28     HtmlParser._processBeforesAndAfters (package:flutter_html/html_parser.dart:557:21)
flutter: #29     List.forEach (dart:core-patch/growable_array.dart:403:8)
flutter: #30     HtmlParser._processBeforesAndAfters (package:flutter_html/html_parser.dart:557:21)
flutter: ...
flutter: ...
flutter: #5805   ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4520:16)
flutter: #5806   Element.rebuild (package:flutter/src/widgets/framework.dart:4189:5)
flutter: #5807   ProxyElement.update (package:flutter/src/widgets/framework.dart:4843:5)
flutter: #5808   Element.updateChild (package:flutter/src/widgets/framework.dart:3293:15)
flutter: #5809   SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5981:14)
flutter: #5810   Element.updateChild (package:flutter/src/widgets/framework.dart:3293:15)
flutter: #5811   ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4520:16)
flutter: #5812   Element.rebuild (package:flutter/src/widgets/framework.dart:4189:5)
flutter: #5813   StatelessElement.update (package:flutter/src/widgets/framework.dart:4576:5)
flutter: #5814   Element.updateChild (package:flutter/src/widgets/framework.dart:3293:15)
flutter: #5815   SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5981:14)
flutter: #5816   Element.updateChild (package:flutter/src/widgets/framework.dart:3293:15)
flutter: #5817   SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5981:14)
flutter: #5818   Element.updateChild (package:flutter/src/widgets/framework.dart:3293:15)
flutter: #5819   RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:5503:32)
flutter: #5820   MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6105:17)
flutter: #5821   Element.updateChild (package:flutter/src/widgets/framework.dart:3293:15)
flutter: #5822   SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5981:14)
flutter: #5823   Element.updateChild (package:flutter/src/widgets/framework.dart:3293:15)
flutter: #5824   ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4520:16)
flutter: #5825   StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4667:11)
flutter: #5826   Element.rebuild (package:flutter/src/widgets/framework.dart:4189:5)
flutter: #5827   StatefulElement.update (package:flutter/src/widgets/framework.dart:4699:5)
flutter: #5828   Element.updateChild (package:flutter/src/widgets/framework.dart:3293:15)
flutter: #5829   ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4520:16)
flutter: #5830   Element.rebuild (package:flutter/src/widgets/framework.dart:4189:5)
flutter: #5831   StatelessElement.update (package:flutter/src/widgets/framework.dart:4576:5)
flutter: #5832   Element.updateChild (package:flutter/src/widgets/framework.dart:3293:15)
flutter: #5833   ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4520:16)
flutter: #5834   Element.rebuild (package:flutter/src/widgets/framework.dart:4189:5)
flutter: #5835   BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2694:33)
flutter: #5836   WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:873:21)
flutter: #5837   RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:319:5)
flutter: #5838   SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1144:15)
flutter: #5839   SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1082:9)
flutter: #5840   SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:865:7)
flutter: (elided 4 frames from class _RawReceivePortImpl, class _Timer, and dart:async-patch)
flutter:
flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════
flutter: ----------------FIREBASE CRASHLYTICS----------------
flutter: The following exception was thrown building HtmlParser(dirty, dependencies: [_InheritedTheme, _LocalizationsScope-[GlobalKey#b3a97], MediaQuery]):
flutter: Stack Overflow
flutter: 
debugCreator: HtmlParser ← ConstrainedBox ← Container ← Html ← TMXHtml ← DefaultTextStyle ← AnimatedDefaultTextStyle ← _InkFeatures-[GlobalKey#5742b ink renderer] ← NotificationListener<LayoutChangedNotification> ← PhysicalModel ← AnimatedPhysicalModel ← Material ← ⋯
flutter: 
#0      new Object (dart:core/object.dart:24:3)
#1      new StyledElement (package:flutter_html/src/styled_element.dart)
#2      new ReplacedElement (package:flutter_html/src/replaced_element.dart:32:8)
#3      new TextContentElement (package:flutter_html/src/replaced_element.dart:55:8)
#4      HtmlParser._processBeforesAndAfters (package:flutter_html/html_parser.dart:551:14)
#5      List.forEach (dart:core-patch/growable_array.dart:403:8)
#6      HtmlParser._processBeforesAndAfters (package:flutter_html/html_parser.dart:557:21)
#7      List.forEach (dart:core-patch/growable_array.dart:403:8)
#8      HtmlParser._processBeforesAndAfters (package:flutter_html/html_parser.dart:557:21)
#9      List.forEach (dart:core-patch/growable_array.dart:403:8)
#10     HtmlParser._processBeforesAndAfters (package:flutter_html/html_parser.dart:557:21)
#11     List.forEach (dart:core-patch/growable_array.dart:403:8)
#12     HtmlParser._processBeforesAndAfters (package:flutter_html/html_parser.dart:557:<…>
flutter: ----------------------------------------------------
Reloaded 265 of 2400 libraries in 1.815ms.

We're currently using this commit: 4b153dd

@tneotia
Copy link
Collaborator

tneotia commented May 1, 2021

@DFelten it should look like this correct?

image

 Html(
          data: '<p class="test">This is a test with before and after tag</p>',
          style: {
            '.test': Style(
              before: 'test',
              after: 'test'
            ),
          },
        ),

@DFelten
Copy link
Contributor Author

DFelten commented May 1, 2021

That's the expected behavior, yes.

@tneotia
Copy link
Collaborator

tneotia commented May 1, 2021

Great. Fixed above, there was an infinite loop running due to the before/after property being cascaded to the before/after child itself, which runs the before/after code again, etc...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants