2017-01-09 102 views

回答

10

您應該使用RichText部件。

RichText小部件將採用TextSpan小部件,該小部件也可以具有子級TextSpans的列表。

每個TextSpan小部件可以有不同的TextStyle

下面是示例代碼來呈現: 你好世界

var text = new RichText(
    text: new TextSpan(
    // Note: Styles for TextSpans must be explicitly defined. 
    // Child text spans will inherit styles from parent 
    style: new TextStyle(
     fontSize: 14.0, 
     color: Colors.black, 
    ), 
    children: <TextSpan>[ 
     new TextSpan(text: 'Hello'), 
     new TextSpan(text: 'World', style: new TextStyle(fontWeight: FontWeight.bold)), 
    ], 
), 
); 
相關問題