将按钮移至底部
我试图将按钮移至屏幕的底部,但徒劳无功。我基本上有2个Textediting Controllers和一个按钮,但后者一直坚持使用TextedingController。有什么建议吗?
return Scaffold(
body: SafeArea(
child: SingleChildScrollView(
physics: const ScrollPhysics(),
child: Column(
children: [
return Card(
elevation: 5,
clipBehavior: Clip.antiAlias,
margin: const EdgeInsets.all(0),
child: Container(
padding: const EdgeInsets.all(15),
child: Row(
children: [
Column(
),
Expanded(
child: Column(
children: [
LocationField(
isDestination: false,
textEditingController: sourceController),
LocationField(
isDestination: true,
textEditingController: destinationController),
],
),
),
Align(
alignment: Alignment.bottomCenter,
child: Container(
margin: const EdgeInsets.all(5),
width: double.infinity,
child: ElevatedButton(
onPressed: () {},
child: const Text('Bottom Button '), // trying to move to the bottom
),
),
)
],
);
}
I am trying to move the button to the bottom of the screen but in vain. I basically have 2 textEditingControllers and a button but the latter keeps sticking with the textEditingController. Any advice, please?
return Scaffold(
body: SafeArea(
child: SingleChildScrollView(
physics: const ScrollPhysics(),
child: Column(
children: [
return Card(
elevation: 5,
clipBehavior: Clip.antiAlias,
margin: const EdgeInsets.all(0),
child: Container(
padding: const EdgeInsets.all(15),
child: Row(
children: [
Column(
),
Expanded(
child: Column(
children: [
LocationField(
isDestination: false,
textEditingController: sourceController),
LocationField(
isDestination: true,
textEditingController: destinationController),
],
),
),
Align(
alignment: Alignment.bottomCenter,
child: Container(
margin: const EdgeInsets.all(5),
width: double.infinity,
child: ElevatedButton(
onPressed: () {},
child: const Text('Bottom Button '), // trying to move to the bottom
),
),
)
],
);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您在脚手架中,并且想要在屏幕上的固定位置中放置一些按钮,则可以使用FloatingActionButton属性。
示例:
当然,FloatingActionButton属性是Mainy用于FloatingActionButton,但是很高兴知道您可以将任何窗口小部件(其他类型的按钮,行,列等)放在那里。为了定位此小部件,您可以使用“ FloatingActionButtonLocation”脚手架属性。
If you are in Scaffold and want to have some Button in a fixed position on the screen you can use floatingActionButton Property.
Example:
Of course floatingActionButton property is mainy used for FloatingActionButton but it's good to know that you can put there any widget (other types of buttons, Rows, Columns and others). For positioning this widget you can use 'floatingActionButtonLocation' Scaffold property.
尝试以下代码
结果 - >
Try below code
Result->
您可以通过在代码中进行少量更改来实现它。您必须如下更改代码树。
这将使按钮移至屏幕末端。我希望这就是您要做的。
但是这样,使屏幕上剩下的小部件将滚动的按钮可见。
You can achieve it by making small changes in your code it self. you have to change the tree of your code as below.
This will make the Button to move to the end of the screen. I hope thats what you are trying to do.
But this way makes the Button visible on the screen all the time where as remaining widgets will be scrolling.
假设它包裹在列小部件中,只需使用间隔窗口小部件即可。不确定它的好解决方案是否仍然是初学者。
Assuming it is wrapped in a column widget, just use Spacer widget. Not really sure if its good solution Im still a beginner.