Refactor _applyCustomAttributes function

pull/371/head
Xin Yao 4 years ago
parent 7523d9623f
commit bd41d77e85
  1. 16
      lib/src/widgets/text_line.dart

@ -37,6 +37,7 @@ class TextLine extends StatelessWidget {
final DefaultStyles styles;
final bool readOnly;
final StyleBuilder? styleBuilder;
@override
Widget build(BuildContext context) {
assert(debugCheckHasMediaQuery(context));
@ -157,15 +158,14 @@ class TextLine extends StatelessWidget {
TextStyle _applyCustomAttributes(
TextStyle textStyle, Map<String, Attribute> attributes) {
if (styleBuilder != null) {
attributes.keys
.where((key) => !attributes.containsKey(key))
.forEach((key) {
/// Custom Attribute
final customAttr = styleBuilder!.call(key);
textStyle = textStyle.merge(customAttr);
});
if (styleBuilder == null) {
return textStyle;
}
attributes.keys.where((key) => !attributes.containsKey(key)).forEach((key) {
/// Custom Attribute
final customAttr = styleBuilder!.call(key);
textStyle = textStyle.merge(customAttr);
});
return textStyle;
}

Loading…
Cancel
Save