styled_text_package icon indicating copy to clipboard operation
styled_text_package copied to clipboard

Is it possible to pass StyledText.style to StyledTextTagBase

Open fingerart opened this issue 7 months ago • 0 comments

Example 1:

  // <linear-gradient from="theme_color_name|hex_number" to="theme_color_name|hex_number" />
  'linear-gradient': StyledTextWidgetBuilderTag(
    (context, attributes, text) {
      final from = attributes['from'];
      final to = attributes['to'];
      Color? fromColor = _parseColor(context, from);
      Color? toColor = _parseColor(context, to);

      return ShaderMask(
        shaderCallback: (rect) => LinearGradient(
          colors: [fromColor, toColor],
          begin: Alignment.topLeft,
          end: Alignment.topRight,
        ).createShader(rect),
        child: Text(text, style: style), // Unable to inherit size of StyledText.style
      );
    },
    alignment: PlaceholderAlignment.baseline,
  ),

Example 2:

// <font size="relative_size" />
'font': StyledTextCustomTag(parse: (context, baseStyle, attributes) {
    final rawSize = attributes['size'];// Support relative size

   fial size = StyledText.style.copyWith(size: StyledText.style.size + rawSize);

    return TextStyle(fontSize: size);
  }),

fingerart avatar Jun 27 '24 08:06 fingerart