auto_hyphenating_text icon indicating copy to clipboard operation
auto_hyphenating_text copied to clipboard

Add support for Text.rich

Open dbebawy opened this issue 2 years ago • 4 comments

My implementation leverages Text.rich. Is this something that you can support?

dbebawy avatar Jan 25 '24 09:01 dbebawy

What do you mean? The widget should already use rich text.

impure avatar Jan 26 '24 01:01 impure

I'm using the RichText widget. This is my code snippet:

Text.rich(
  TextSpan(
    style: TextStyle(
      color: textColor,
      fontFamily: lang.fontFamily,
      fontSize: preferenceController.fontSize.value,
      fontStyle: fontStyle,
    ),
    children: [
      TextSpan(
        children: <InlineSpan>[
          WidgetSpan(
            alignment: PlaceholderAlignment.top,
            child: Text(
              line.getString() ?? '',
              textScaler: const TextScaler.linear(.5),
              style: TextStyle(
                color: textColor,
                fontSize: preferenceController.fontSize.value,
                fontFeatures: const <FontFeature>[
                  FontFeature.superscripts(),
                ],
              ),
            ),
          ),
          TextSpan(
            text: line.getString2(),
          ),
        ],
      ),
    ],
  ),
  textAlign: TextAlign.justify,
  textDirection: lang.textDirection,
)

When I attempt to replace Text.rich( with AutoHyphenatingText.rich(, I receive this error message:

The method 'rich' isn't defined for the type 'AutoHyphenatingText'.
Try correcting the name to the name of an existing method, or defining a method named 'rich'.

Does it work with other languages? Which languages are currently supported?

dbebawy avatar Feb 14 '24 07:02 dbebawy

@impure , Any updates?

dbebawy avatar Sep 06 '25 08:09 dbebawy

This isn't supported, it's supposed to be a drop in replacement for Text or SelectableText. Adding arbitrary TextSpan support would be too complicated.

impure avatar Sep 07 '25 02:09 impure