相关疑难解决方法(0)

如何为我的小部件添加边距?了解EdgeInsets的效果

我试图将我的头围绕在Flutter的ui位置.所以我现在有一些看起来像这样的东西 在此输入图像描述

我想添加一点空格黑白搜索Textfield和按钮.这就是我的代码的控制部分.我试图设计我的样式,textFieldSearchBox所以它右边有一点边距,我试图增加Edge插件,但它似乎增加了TextField的大小我不知道为什么?我知道我可以在TextField之后添加一个填充元素,但我想知道我的其他选项是什么.为什么在textFieldSearchBox的装饰中增加EdgeInsets会增加文本框的大小?我理想的情况是在此文本框(LTRB)的所有边界周围添加边距.有什么建议?

TextField textFieldSearchBox = new TextField(
            keyboardType: TextInputType.text,
            controller: filterController,
            autofocus: false,
            decoration: new InputDecoration(
                contentPadding: new EdgeInsets.fromLTRB(20.0, 10.0, 100.0, 10.0),
                border:
                new OutlineInputBorder(borderRadius: BorderRadius.only()),
            ),
        );

    var optionRow = new Row(
            children: <Widget>[
                new Expanded(child:textFieldSearchBox),
                searchButton,
                new IconButton(
                    icon: new Icon(Icons.filter),
                    onPressed: (){print("Called....");},
                ),
            ],
        );

    return new Scaffold(
                appBar: new AppBar(
                    title: new Text("Title goes here.."),
                    backgroundColor: Colors.lightBlueAccent,
                ),
                body: new Container(
                    child:new Column(
                        children: <Widget>[
                            optionRow,

                        ],
                    ),
                ),
        );
Run Code Online (Sandbox Code Playgroud)

flutter flutter-layout

13
推荐指数
4
解决办法
2万
查看次数

标签 统计

flutter ×1

flutter-layout ×1