feat: lineThrough and underline can coexist

This commit is contained in:
Lucas.Xu 2022-08-09 10:44:00 +08:00
parent 585c9f8753
commit 06d11a91d1
2 changed files with 7 additions and 9 deletions

View File

@ -204,12 +204,15 @@ class RichTextStyle {
// underline or strikethrough
TextDecoration get textDecoration {
var decorations = [TextDecoration.none];
if (attributes.underline || attributes.href != null) {
return TextDecoration.underline;
} else if (attributes.strikethrough) {
return TextDecoration.lineThrough;
decorations.add(TextDecoration.underline);
// TextDecoration.underline;
}
return TextDecoration.none;
if (attributes.strikethrough) {
decorations.add(TextDecoration.lineThrough);
}
return TextDecoration.combine(decorations);
}
// font

View File

@ -97,11 +97,6 @@ bool formatRichTextPartialStyle(EditorState editorState, String styleKey) {
Attributes attributes = {
styleKey: value,
};
if (styleKey == StyleKey.underline && value) {
attributes[StyleKey.strikethrough] = null;
} else if (styleKey == StyleKey.strikethrough && value) {
attributes[StyleKey.underline] = null;
}
return formatRichTextStyle(editorState, attributes);
}