【问题标题】:How can I create a multiple line text so that each line (row) is centered?如何创建多行文本以使每一行(行)居中?
【发布时间】:2022-11-19 20:08:14
【问题描述】:
body: SingleChildScrollView(
        child: Padding(
          padding: const EdgeInsets.only(top: 20, left: 15, right: 15),
          child: Padding(
            padding: const EdgeInsets.only(top: 10),
            child: ClipRRect(
              borderRadius: BorderRadius.circular(15),
              child: Container(
                height: 500,
                color: const Color.fromARGB(255, 35, 35, 35),
                child: Padding(
                  padding: const EdgeInsets.only(top: 20),
                  child: Column(children: const [
                    Text(
                      'Student Space',
                      style: TextStyle(
                        color: Colors.white,
                        fontSize: 30,
                        fontWeight: FontWeight.bold,
                      ),
                    ),
                    SizedBox(
                      height: 20,
                    ),
                    Text('This is a very very very long text that should be centered just like the first text in this column. I don't want to cut it for each row.',
                      style: TextStyle(
                        color: Colors.white,
                        fontSize: 20,
                        fontWeight: FontWeight.w400,
                      ),
                    ),
                  ]),
                ),
              ),
            ),
          ),
        ),
      ),

我希望文本看起来就像您在 Word 中将文本居中一样。如果不将每一行的文本拆分为单独的文本,我无法弄清楚如何执行此操作。

【问题讨论】:

    标签: flutter flutter-text


    【解决方案1】:

    使用" " 更改到下一行并使用textAlign 作为TextAlign.center 使文本居中

    Text('Something went wrong 
    Please try again',textAlign: TextAlign.center,);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-08-01
      • 2022-11-15
      • 1970-01-01
      • 2015-08-04
      • 1970-01-01
      • 1970-01-01
      • 2023-02-02
      • 1970-01-01
      相关资源
      最近更新 更多