From bd41d77e854d2fa1b0ab286b16d8ef5f0586f8e2 Mon Sep 17 00:00:00 2001 From: Xin Yao Date: Thu, 19 Aug 2021 01:19:42 -0700 Subject: [PATCH] Refactor _applyCustomAttributes function --- lib/src/widgets/text_line.dart | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/src/widgets/text_line.dart b/lib/src/widgets/text_line.dart index e45a45b4..65a661b5 100644 --- a/lib/src/widgets/text_line.dart +++ b/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 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; }