Flutter中Text溢出

1,985 阅读1分钟

很多时候我们使用Text是在Row或者Colunms中,这个时候单单是设置overflow没用的,需要使用Flex和Expanded,如:

Flex(
                direction: Axis.horizontal,
                children: <Widget>[
                  Text("juejin:"),
                  Expanded(
                      child: Text.rich(TextSpan(children: [

                    TextSpan(
                        text:
                            "https://juejin.cn/user/2963939077919063",
                        recognizer: tap,
                        style: TextStyle(
                            color: Colors.red,
                            decoration: TextDecoration.underline,
                            fontWeight: FontWeight.bold)),
                  ]),textScaleFactor: 0.8,)),
                ],
    )