我需要展示..。如果文本溢出并单击,则需要显示全文。所以我使用PopupMenuButton,一切都很好,但问题是它只显示3个字母表和显示…然后我知道宽度很短,但在我使用这个文本之前,它显示了大约10个单词,我认为有一些填充或其他东西,我有足够的宽度来显示更多的文本,但它没有显示
Container(
child: Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: [
Container(
width: Width *
0.225,
child:
Align(
alignment:
Alignment.topLeft,
child: PopupMenuButton<
String>(
icon:
Container(
child: Text(datashowThis[index]['data'][i]['serviceName'] != null ? datashowThis[index]['data'][i]['serviceName'] : '',
textAlign: TextAlign.left,
overflow: TextOverflow.ellipsis,
maxLines: 1,
softWrap: false,
style: TextStyle(color: textGreyColor, fontSize: 12, fontFamily: 'SegoeUI-SemiBold')),
),
onSelected:
(choice) {},
itemBuilder:
(BuildContext context) {
return [
'${datashowThis[index]['data'][i]['serviceName']}'
].map((String
choice) {
return PopupMenuItem<String>(
value: choice,
child: Container(width: 100, child: Text(choice, style: TextStyle(color: kPrimaryColor, fontFamily: 'SegoeUI'))),
);
}).toList();
},
),
),
),
Container(
width: Width *
0.16,
child:
Center(
child: Text(
datashowThis[index]['data'][i]['hourBooked_Productivity']
.toString(),
textAlign: TextAlign
.center,
style: TextStyle(
color: textGreyColor,
fontSize: 12,
fontFamily: 'SegoeUI-SemiBold')),
),
),
Container(
width: Width *
0.16,
child:
Center(
child: Text(
datashowThis[index]['data'][i]['hourScheduled_Productivity']
.toString(),
textAlign: TextAlign
.center,
style: TextStyle(
color: textGreyColor,
fontSize: 12,
fontFamily: 'SegoeUI-SemiBold')),
),
),
Container(
width:
Width *
0.2,
child:
Center(
child: Text(
datashowThis[index]['data'][i]['appointmentsBooked_Productivity']
.toString(),
textAlign: TextAlign
.center,
style: TextStyle(
color: textGreyColor,
fontSize: 12,
fontFamily: 'SegoeUI-SemiBold')),
),
),
Container(
width: Width *
0.15,
child:
Center(
child: Text(
datashowThis[index]['data'][i]['bookedPercentange_Productivity']
.toString(),
textAlign: TextAlign
.center,
style: TextStyle(
color: textGreyColor,
fontSize: 12,
fontFamily: 'SegoeUI-SemiBold')),
),
),
],
),
);你可以在图片上看到问题

发布于 2021-09-28 05:34:24
问题是你把其他的小部件放在了需要图标小部件的地方。所以它的默认图标宽度是采用的。
解决方案:
在PopUpMenuButton小部件中使用子图标而不是‘’。下面是一个例子:
Container(
width: ProjectResource.screenWidth * 0.4,
color: AppColors.blueColor,
child: Align(
alignment: Alignment.topLeft,
child: PopupMenuButton<String>(
child: Container(
color: AppColors.greenColor,
child: Text('Data here sa as a a a as asas a',
textAlign: TextAlign.left,
style: TextStyle(
color: AppColors.whiteColor,
fontSize: 12,
)),
),
onSelected: (choice) {},
itemBuilder: (BuildContext context) {
return ['Data here'].map((String choice) {
return PopupMenuItem<String>(
value: choice,
child: Container(
width: ProjectResource.screenWidth * 0.225,
child: Text(choice,
style: TextStyle(color: AppColors.greenColor))),
);
}).toList();
},
),
),
)所以你可以使用任何宽度和高度的PopUpMenuButton子级。谢谢。

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