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

customStyleBuilder Does Not Accumulate Styles for Multiple Attributes #2425

Open
1 task done
manudicri opened this issue Jan 1, 2025 · 0 comments
Open
1 task done
Labels
question Further information is requested

Comments

@manudicri
Copy link

Is there an existing issue for this?

The question

The customStyleBuilder in flutter_quill does not accumulate styles when multiple attributes are applied to the same text. Instead, it processes each attribute independently, leading to only the last attribute being applied. This behavior makes it impossible to correctly combine styles like bold, italic, underline, and custom font sizes.

Steps to Reproduce

Create a QuillEditor with a customStyleBuilder to handle custom styles.
Apply multiple styles (e.g., bold, italic, and size) to the same text.
Observe that only one of the styles is applied (the last one processed).

Expected Behavior

All styles (bold, italic, underline, size, etc.) should be combined into a single TextStyle and applied simultaneously to the text.

Actual Behavior

Only one style (the last one processed by customStyleBuilder) is applied, overriding any previously applied styles.

Example Code

configurations: QuillEditorConfigurations(
  customStyleBuilder: (attribute) {
    // basically settings.fontSize is the size factor of a zoom mechanism already implemented, so i can make the text larger or smaller by pinching the screen, without modifying the quill editor document
    TextStyle style = DefaultTextStyle.of(context).style.copyWith(fontSize: settings.fontSize * 20);

    if (attribute.key == "bold" && attribute.value == true) {
      style = style.copyWith(fontWeight: FontWeight.bold);
    }
    if (attribute.key == "italic" && attribute.value == true) {
      style = style.copyWith(fontStyle: FontStyle.italic);
    }
    if (attribute.key == "underline" && attribute.value == true) {
      style = style.copyWith(decoration: TextDecoration.underline);
    }
    // the thing I need the most, specific size attribute 
    if (attribute.key == "size") {
      final size = double.parse(attribute.value.toString());
      style = style.copyWith(fontSize: settings.fontSize * size);
    }

    return style;
  },
)

(read comments)

Can you help me with this? Thank you so much

@manudicri manudicri added the question Further information is requested label Jan 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant