如何连接两个TextStyle?

J K*_*Kim 4 dart flutter

我想连接两个 TextStyle,如 react 或 react-native。

    style={[styles.firstStyle, styles.secondStyle]}
Run Code Online (Sandbox Code Playgroud)

但我不知道如何在颤振中做到这一点。如何得到如下结果?

    TextStyle(color: Colors.white, fontFamily: CUSTOM)
Run Code Online (Sandbox Code Playgroud)

这与:

    TextStyle(color: Colors.black, fontSize: 17)
Run Code Online (Sandbox Code Playgroud)

结果如下。

    TextStyle(color: Colors.black, fontFamily: CUSTOM, fontSize: 17)
Run Code Online (Sandbox Code Playgroud)

Mul*_*dec 8

您可以使用合并方法

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

var mergedStyle = firstStyle.merge(secondStyle);
Run Code Online (Sandbox Code Playgroud)