首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >强制列中的小部件与最大值匹配

强制列中的小部件与最大值匹配
EN

Stack Overflow用户
提问于 2019-11-28 23:56:12
回答 1查看 18关注 0票数 0

我在一个列中有几个RaisedButton小部件,它们根据文本的不同具有不同的宽度。我希望它们是相同的宽度,但我不想设置静态宽度,因为它应该能够响应语言和屏幕大小/形状的变化。应调整较小的小部件的大小,以与列中最大的小部件的宽度相匹配。做这件事最好的方法是什么?

谢谢!

代码语言:javascript
复制
Column(
                children: <Widget>[
                  RaisedButton(
                      child: Text("Btn1"),
                      onPressed: (){},
                  ),
                  RaisedButton(
                      child: Text("LongerBtn2"),
                      color: Colors.Red,
                      onPressed: (){},
                  )
                ],
              ),
EN

Stack Overflow用户

发布于 2019-11-29 00:06:19

可以这样做:

代码语言:javascript
复制
        IntrinsicWidth( // <- Sizes its child's width to the child's maximum intrinsic width
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.stretch, // <- all children will try to take as much space as possible 
            children: <Widget>[
              RaisedButton(
                child: Text("Btfffffff fsdfds dsfsa n1"),
                color: Colors.green,
                onPressed: () {},
              ),
              RaisedButton(
                child: Text("LongerBtn2"),
                color: Colors.red,
                onPressed: () {},
              )
            ],
          ),
        )
票数 1
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59092541

复制
相关文章

相似问题

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