J Kim
J Kim

Reputation: 113

How to concatenate two TextStyle?

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)

Upvotes: 11

Views: 5420

Answers (1)

Muldec
Muldec

Reputation: 4901

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);

Upvotes: 28

Related Questions