首页 > 解决方案 > Flutter 代码中的文本溢出不起作用

问题描述

我正在尝试省略 Flutter 应用程序中的文本,但我无法设置它。

我设计的视图如下

Positioned(
            bottom: 20,
            left: 10,
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Text(
                  snapshot.data.results[index].title,
                  overflow: TextOverflow.ellipsis,
                  textAlign: TextAlign.start,
                  style: TextStyle(
                    fontSize: 20.0,
                    fontWeight: FontWeight.w600,
                    color: Colors.white,
                  ),
                ),
                Text(
                  snapshot.data.results[index].release_date,
                  style: TextStyle(
                      fontSize: 18.0,
                      fontWeight: FontWeight.w400,
                      color: Colors.white,
                      letterSpacing: 1.2),
                ),
              ],
            ))

屏幕截图省略号

标签: flutterdartflutter-layout

解决方案


Flexible您应该使用或小部件包装您的文本,Expanded如下所示:

    Flexible(child:Text("Text goes here"),

欲了解更多信息,请尝试链接


推荐阅读