Skip to content

Add support for WidgetSpan #89

@JCKodel

Description

@JCKodel

I created an extension to be able to render icons in the mardown.

This is done by typing [i:package;fontName;code], so, for instance, a radio button and a check button would be rendered as:

[i:null;MaterialIcons;0xe503;null] representa uma opção de escolha única, ou seja, você pode escolher apenas uma das opções indicadas.

[i:null;MaterialIcons;0xef46;null] representa uma opção de escolha múltipla, ou seja, você poderá escolher quantas opções desejar.

Problem is: Flutter doesn't render symbols very well (they are not in the same vertical alignment):

image

Since TextSpan doesn't have any kind of fix for position, the only way would be to use WidgetSpan, so we could use any widget inside a RichText with a Transform.translate to fix the vertical alignment.

Unfortunately, using WidgetSpan triggers an error here:

https://github.com/tagnote-app/markdown_viewer/blob/b94b9ca0eef56d1beaf899a00aeff529cd24f67f/lib/src/helpers/merge_rich_text.dart#L45

saying WidgetSpan is not a TextSpan.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions