如何在子视图中将子视图放置在多个位置?

问题描述 投票:0回答:1

我有一个登录页面,该页面具有三个字段和一个位于页面中心的按钮。在同一页面的底部,我需要垂直显示三个按钮。如何在Flutter中做到这一点?任何建议都将非常有帮助。提前感谢。

flutter dart flutter-layout
1个回答
0
投票

您的问题不清楚,我想您需要在列的底部放置3个按钮。

return Scaffold(
      appBar: AppBar(),
      body: Container(
        padding:
            EdgeInsets.only(left: 20.0, right: 20.0, top: 25.0, bottom: 25.0),
        child: Column(
          children: <Widget>[
            TextField(
              decoration: InputDecoration(hintText: 'Text Field 1'),
            ),
            TextField(
              decoration: InputDecoration(hintText: 'Text Field 2'),
            ),
            TextField(
              decoration: InputDecoration(hintText: 'Text Field 3'),
            ),
            SizedBox(
              height: 25.0,
            ),
            MaterialButton(
              onPressed: () {},
              child: Text('Button'),
              color: Colors.blue,
              minWidth: double.infinity,
            ),
            Expanded(
              child: SizedBox(),
            ),
            MaterialButton(
              onPressed: () {},
              child: Text('Button 1'),
              color: Colors.blue,
              minWidth: double.infinity,
            ),
            MaterialButton(
              onPressed: () {},
              child: Text('Button 2'),
              color: Colors.blue,
              minWidth: double.infinity,
            ),
            MaterialButton(
              onPressed: () {},
              child: Text('Button 3'),
              color: Colors.blue,
              minWidth: double.infinity,
            ),
          ],
        ),
      ),
    );

[Expanded将填补空白

结果会像enter image description here

如果您的问题不同,请给我更多详细信息

© www.soinside.com 2019 - 2024. All rights reserved.