首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >颤动PopupMenuButton填充或全宽

颤动PopupMenuButton填充或全宽
EN

Stack Overflow用户
提问于 2021-09-27 20:24:16
回答 1查看 129关注 0票数 1

我需要展示..。如果文本溢出并单击,则需要显示全文。所以我使用PopupMenuButton,一切都很好,但问题是它只显示3个字母表和显示…然后我知道宽度很短,但在我使用这个文本之前,它显示了大约10个单词,我认为有一些填充或其他东西,我有足够的宽度来显示更多的文本,但它没有显示

代码语言:javascript
复制
   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')),
          ),
        ),
      ],
    ),
  );

你可以在图片上看到问题

EN

回答 1

Stack Overflow用户

发布于 2021-09-28 05:34:24

问题是你把其他的小部件放在了需要图标小部件的地方。所以它的默认图标宽度是采用的。

解决方案:

在PopUpMenuButton小部件中使用子图标而不是‘’。下面是一个例子:

代码语言:javascript
复制
    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子级。谢谢。

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

https://stackoverflow.com/questions/69352845

复制
相关文章

相似问题

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