defaultStyleBuilder function
Creates TextStyles
for the standard SuperEditor.
Implementation
TextStyle defaultStyleBuilder(Set<Attribution> attributions) {
TextStyle newStyle = const TextStyle();
for (final attribution in attributions) {
if (attribution == boldAttribution) {
newStyle = newStyle.copyWith(
fontWeight: FontWeight.bold,
);
} else if (attribution == italicsAttribution) {
newStyle = newStyle.copyWith(
fontStyle: FontStyle.italic,
);
} else if (attribution == underlineAttribution) {
newStyle = newStyle.copyWith(
decoration: newStyle.decoration == null
? TextDecoration.underline
: TextDecoration.combine([TextDecoration.underline, newStyle.decoration!]),
);
} else if (attribution == strikethroughAttribution) {
newStyle = newStyle.copyWith(
decoration: newStyle.decoration == null
? TextDecoration.lineThrough
: TextDecoration.combine([TextDecoration.lineThrough, newStyle.decoration!]),
);
} else if (attribution is LinkAttribution) {
newStyle = newStyle.copyWith(
color: Colors.lightBlue,
decoration: TextDecoration.underline,
);
}
}
return newStyle;
}