首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ListTile susbtitle renderflex溢出

ListTile susbtitle renderflex溢出
EN

Stack Overflow用户
提问于 2021-08-20 09:29:33
回答 2查看 37关注 0票数 0

我有像这样的ListTile副标题:

代码语言:javascript
复制
     subtitle:Flexible(flex:1,child:Row(children: [
                    (widget.condiments!=null)?Padding(
                 child:Text(condimentList,style: TextStyle(color:Colors.grey)),
                   padding: EdgeInsets.only(top: 10)):null,
               ])),
 trailing:  Row(             
            mainAxisSize: MainAxisSize.min,     
            children: <Widget>[
              IconButton(
              icon: Icon(Icons.delete))])

我收到以下错误:

代码语言:javascript
复制
A RenderFlex overflowed by 244 pixels on the right.
The relevant error-causing widget was
Row

我希望用Flexible包装它应该可以解决这个问题,但我似乎不太知道如何解决它。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2021-08-20 10:09:04

只需对文本进行扩展即可,不需要对行使用换行。

dartpad上检查UI输出。

代码语言:javascript
复制
ListTile(
      title: const Text('Test'),
      trailing: Row(mainAxisSize: MainAxisSize.min, children: <Widget>[
        IconButton(onPressed: () {}, icon: const Icon(Icons.delete))
      ]),
      subtitle: Row(children: const [
        Expanded(
            child: Padding(
          padding: EdgeInsets.all(5),
          child: Text(
            'This is a test & this will have a very long paragragh to check the errors once. This is a test & this will have a very long paragragh to check the errors once.',
          ),
        ))
      ]),
    );

展开后的UI输出:

未展开的UI输出:

票数 1
EN

Stack Overflow用户

发布于 2021-08-20 09:32:03

代码语言:javascript
复制
SizedBox(
  width : MediaQuery.of(context).size.width,
  child:  Row(children: [
                (widget.condiments!=null)?Padding(
             child:Text(condimentList,style: TextStyle(color:Colors.grey)),
               padding: EdgeInsets.only(top: 10)),
           ]),
):null;
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68860006

复制
相关文章

相似问题

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