Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to concatenate two TextStyle?

Tags:

flutter

dart

I want to concat two TextStyle like react or react-native.

    style={[styles.firstStyle, styles.secondStyle]}

but i don't know how to do this in flutter. How to result like below?

    TextStyle(color: Colors.white, fontFamily: CUSTOM)

This concatenate with:

    TextStyle(color: Colors.black, fontSize: 17)

result is below.

    TextStyle(color: Colors.black, fontFamily: CUSTOM, fontSize: 17)
like image 769
J Kim Avatar asked Jul 23 '19 09:07

J Kim


1 Answers

You can use the merge method.

var firstStyle = TextStyle(color: Colors.white, fontFamily: CUSTOM);
var secondStyle = TextStyle(color: Colors.black, fontSize: 17);

var mergedStyle = firstStyle.merge(secondStyle);
like image 137
Muldec Avatar answered Nov 09 '22 23:11

Muldec