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

Loading…
Cancel
Save