Flutter_widget_from_html: Problem with custom tag handling

Created on 5 Mar 2019  路  7Comments  路  Source: daohoangson/flutter_widget_from_html

I try to use the following code to handle <blockquote> tag:

case 'blockquote':
    meta = lazySet(meta,
    color: theme.hintColor,
    buildOp: BuildOp(
          isBlockElement: true,
          onWidgets: (widgets) {
            return <Widget>[Blockquote(child: this.buildColumn(widgets))];
          },
        ));
break;

The Blockquote widget is a container with left board and I have set a default text color to it.
When rendering the following html code:

<blockquote>some text before span <span style="color: red;">testing</span> text after span</blockquote>

I expect the the text "tesing" is in red color and the remaining text color is the one I have set in parseElement method. However, the text color of text "text after span" is not the one I set.

I am not sure if I implement the custom widget in the right place or is it a bug, please advise.

All 7 comments

I think it's a bug. Let me check.

I have just realized that the library doesn't support color in inline styling. Did you implement that yourself?

I have just realized that the library doesn't support color in inline styling. Did you implement that yourself?

Yes, I did it this way:

 @override
  NodeMetadata parseElementStyle(NodeMetadata meta, String key, String value) {
    meta = super.parseElementStyle(meta, key, value);
    switch (key) {
      case 'font-size':
        meta = lazySet(meta,
            fontSize:
                this.defaultTextStyle.fontSize + _supportedFotSize[value]);
        break;
      case 'color':
        meta = lazySet(meta, color: _supportedColorStyle[value]);
        break;
    }
    return meta;
  }

Nice, I did something similar and found the bug. Let me try and fix it real quick.

I have just released v0.1.2 with the fix, please try upgrading and let me know if it works for you.

Will test on tomorrow
Thanks馃憤馃徎

Works now馃憤馃徎

Was this page helpful?
0 / 5 - 0 ratings

Related issues

forever84721 picture forever84721  路  4Comments

abdhoms picture abdhoms  路  3Comments

SoFo12 picture SoFo12  路  4Comments

mclark4386 picture mclark4386  路  3Comments

ahmadkhedr picture ahmadkhedr  路  7Comments