Closed fedotxxl closed 4 years ago
No, not as a method.
I am kinda moving away from methods which modifies a previously defined widget, like all the text widgets. All thought i havent messuered the performance loss i would rather be on the safe side and define the text style withing the Text
widget. The reason its less performant is because when you call a method which modifies the Text
widget, it copies the old styled and applies the new ones before rendering a new Text
widget. This is the only possibility since the Text
widget is immutable. Therefore i would recommend defining your text style within the Text
widget instead.
final TextStyle _textStyle = TextStyle(/* style */);
Text('text', style: _textStyle)
. //style
So your suggestion is to use TextStyle
for text and extension methods for other cases?
yes, and the same goes for Icon
. I might remove them in the future.
When using multiple DecoratedBox
styles i would also recommend using decorated()
instead of listing each up by their respective method:
Widget()
.backgroundColor(Colors.blue)
.boxShadow()
Widget()
.decorated(
color: Colors.blue,
boxShadow: BoxShadow()
)
Ok, I see. The first approach might have a performance penalty but is it critical in the common app?... It's better to provide simple and usable API which will work in 90% of cases and document the other 10% of cases.
I`m not sure how it actually impacts the performance. Would be interesting to actually test the difference. Probably not a big difference.
Do you have support for the
height
property ofTextStyle
(https://stackoverflow.com/a/58156970/716027)?