IconButton在屏幕边缘占用了太多空间 [英] IconButton takes too much space to the edge of screen

查看:50
本文介绍了IconButton在屏幕边缘占用了太多空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IconButton占用了屏幕边缘太多的空间.这是我的方法:

IconButton takes too much space to the edge of screen. This is how I made it:

return Scaffold(
  body: Column(
    children: [
      Container(
        margin: EdgeInsets.all(20),
        child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [ 
          Row(
             children: <Widget>[
               Expanded(child: Input()),
               IconButton(
                icon: const Icon(Icons.cancel),
                onPressed: () {},
               ),
             ],
        ), ...

它看起来像:

如何修复它以使图标更靠近页边边缘?

How to fix it to make icon closer to the margin edge?

推荐答案

您要查找的是 IconButton 上的 constraints 参数.

What you are looking for is the constraints parameter on the IconButton.

您可以像这样使用它.

constraints: BoxConstraints.tight(Size(24, 24))

有关如何轻松解决这些问题的信息,可以通过查看 IconButton 的内部文档来获得.

Information on how to easily solve these problems can be obtained by checking the internal documentation of your IconButton.

如果您在 IconButton cmd +单击并检查其构建方法,您将看到它正在使用 ConstrainedBox 来确定大小取决于某些因素.

If you cmd + click on the IconButton and check it's build method, you will see that it is using a ConstrainedBox to decide it's size based on some factors.

其中一个因素就是我们传递给小部件的 constraints .

One such factor is the constraints that we pass to the Widget.

这篇关于IconButton在屏幕边缘占用了太多空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆