首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >颤振TextOverflow.ellipsis -字符串末尾不需要的字符

颤振TextOverflow.ellipsis -字符串末尾不需要的字符
EN

Stack Overflow用户
提问于 2022-07-19 08:59:12
回答 1查看 228关注 0票数 0

我想在我的颤振web项目中使用TextOverflow.ellipsis,但是在字符串的末尾,我得到了不想要的char []。我不知道问题出在哪里。下面是一个代码片段:

代码语言:javascript
复制
Container(
          width: (size.width / 2) - 20,
          height: 260,
          decoration: const BoxDecoration(
              borderRadius: BorderRadius.all(Radius.circular(18)),
              color: Colors.white),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              ClipRRect(
                borderRadius: const BorderRadius.only(
                  topLeft: Radius.circular(18),
                  topRight: Radius.circular(18),
                ),
                child: widget.coverPhoto == null ||
                        widget.coverPhoto.the320X240 == null
                    ? SizedBox(
                        width: (size.width / 2),
                        height: 180,
                        child: const Icon(
                          Icons.no_photography_rounded,
                          size: 35,
                          color: Color.fromRGBO(24, 56, 83, 1),
                        ))
                    : Image.network(
                        widget.coverPhoto.the320X240,
                        fit: BoxFit.cover,
                        width: (size.width / 2),
                        height: 180,
                      ),
              ),
              const SizedBox(height: 10),
              Padding(
                padding: const EdgeInsets.symmetric(horizontal: 8),
                child: Text(
                  "This is a sample text for this widget",
                  textAlign: TextAlign.center,
                  overflow: TextOverflow.ellipsis,
                  maxLines: 1,
                  softWrap: false,
                  style: const TextStyle(
                    fontWeight: FontWeight.w600,
                    color: Color.fromRGBO(24, 56, 83, 1),
                  ),
                ),
              ),
              const SizedBox(
                height: 10,
              ),
              MyIconButton(
                title: "Na mapě",
                icon: Icons.location_pin,
                backgroundColor: const Color.fromRGBO(24, 56, 83, 1),
                textColor: Colors.white,
                verticalPadding: 5,
                horizontalPadding: 10,
                textSize: 13,
                spaceBetween: 10,
                iconSize: 15,
                borderRadius: 11,
                onTap: () {
                  if (widget.geoLat != null && widget.geoLong != null) {
                    if (widget.mobileView) {
                      mobileMapController.move(
                          LatLng(widget.geoLat!, widget.geoLong!), 17);
                      myMapController.showMap.value = true;
                    } else {
                      desktopMapController.move(
                          LatLng(widget.geoLat!, widget.geoLong!), 17);
                    }
                  }
                },
              ),
            ],
          ),
        ),

UI输出:

EN

回答 1

Stack Overflow用户

发布于 2022-07-19 09:03:32

使用softWrap: false

代码语言:javascript
复制
Text(
  widget.name,
  textAlign: TextAlign.center,
  overflow: TextOverflow.ellipsis,
  maxLines: 1,
  softWrap: false,
  style: const TextStyle(
    fontWeight: FontWeight.w600,
    color: Color.fromRGBO(24, 56, 83, 1),
  ),
),

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73034046

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档