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

发布于 2022-07-19 09:03:32
使用softWrap: false
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),
),
),

https://stackoverflow.com/questions/73034046
复制相似问题