【问题标题】:Flutter text aligmentFlutter 文本对齐
【发布时间】:2020-10-03 13:41:34
【问题描述】:

我正在使用行来显示此文本。但是,当我使用扩展小部件将第二个文本(例如 AMD Ryzen.../30 天...)设为多行时,第一个文本(例如处理器/操作系统)变为垂直居中,我想要那个垂直顶部。我尝试了一些小部件,如对齐等,但没有奏效。

代码:

Widget _specificationRow(String title, String description) {
  return new Row(children: [
    Padding(
      padding: const EdgeInsets.all(5.0),
      child: Align(
        alignment: Alignment.topRight,
        child: Text(
          '• $title :',
          style: TextStyle(
              color: Colors.deepOrange,
              fontSize: 15.0,
              fontFamily: "GoogleSans"),
        ),
      ),
    ),
    Expanded(
      child: Padding(
        padding: const EdgeInsets.all(5.0),
        child: Text(
          '$description',
          maxLines: 3,
          overflow: TextOverflow.clip,
          style: TextStyle(
              fontSize: 15.0,
              fontFamily: "GoogleSans"),
        ),
      ),
    ),
  ]);
}

【问题讨论】:

    标签: flutter text-alignment


    【解决方案1】:
    Row(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text(
                    '• title : ',
                    style: TextStyle(
                        color: Colors.deepOrange,
                        fontSize: 15.0,
                        fontFamily: "GoogleSans"),
                  ),
                  Expanded(
                    child: Text(
                      'sfdadfafdsfseriewhfkjsvk shfhskdfhs sdfsd fyesruwefkj\nsdfassdfsafdsafd',
                      maxLines: 3,
                      style: TextStyle(fontSize: 15.0, fontFamily: "GoogleSans"),
                    ),
                  ),
                ],
              ),
    

    请提供crossAxisAlignment: CrossAxisAlignment.start

    【讨论】:

      猜你喜欢
      • 2021-11-01
      • 2019-02-19
      • 2021-12-30
      • 2023-04-04
      • 1970-01-01
      • 2018-12-17
      • 2021-08-21
      • 1970-01-01
      • 2019-10-03
      相关资源
      最近更新 更多