不能在flutter的容器中垂直排列文字。

问题描述 投票:0回答:1

我已经试过发布的解决方案 此处 但似乎都不奏效。

        Container(
          child: Center(
            child: Text(
            "Financial Formulas\n",
            textAlign: TextAlign.center,
            style: TextStyle(fontSize: 16),
            ),
          ),
          color: Colors.blue,
          width: 150,
          height: 35,
        ),
user-interface flutter text widget alignment
1个回答
2
投票

当你添加一个 \n 到您的文本,它需要一个额外的行。移除它,您的文本将处于中间位置。

Formulas


0
投票

要将文本换成新的行,使用 /n.

你的情况下,把你的代码改成下面的代码。

   Container(
          child: Center(
            child: Text(
            // Financial will be on a line and Formulas on another line
            "Financial\nFormulas",
            // the text align property tells you how to arrange the texts
            textAlign: TextAlign.center,
            style: TextStyle(fontSize: 16),
            ),
          ),
          color: Colors.blue,
          width: 150,
          height: 35,
        ),

希望能帮到你

© www.soinside.com 2019 - 2024. All rights reserved.