Flutter 编写内联文本

使用Text.rich或者RichText

ListView(
          children: <Widget>[

            Text.rich(
              TextSpan(
                text: 'Text: ',
                children: [
                  TextSpan(text: 'hello '),
                  TextSpan(text: 'world', style: TextStyle(color: Colors.red)),
                ],
              ),
              textScaleFactor: 1.5,
            ),

            new RichText(
              text: new TextSpan(
                text: 'Text: ',
                style: Theme.of(context).textTheme.title,
                children: <TextSpan>[
                  new TextSpan(text: "hello "),
                  new TextSpan(
                    text: "wolrd",
                  ),
                ],
              ),
            ),
          ],
        )

猜你喜欢

转载自www.cnblogs.com/ajanuw/p/10556565.html