sim*_*sim 5 dart flutter flutter-layout
我试图将按钮移至屏幕底部但徒劳。我基本上有 2 个 textEditingController 和一个按钮,但后者一直坚持使用 textEditingController。请问有什么建议吗?
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
),
),
)
],
);
}
Run Code Online (Sandbox Code Playgroud)
小智 10
如果您在 Scaffold 中并希望在屏幕上的固定位置有一些 Button,您可以使用 floatActionButton 属性。
例子:
Scaffold(
floatingActionButtonLocation:
FloatingActionButtonLocation.centerFloat,
floatingActionButton: Container(
height: 50,
margin: const EdgeInsets.all(10),
child: ElevatedButton(
onPressed: () {},
child: const Center(
child: Text('Hello'),
),
),
),
);
Run Code Online (Sandbox Code Playgroud)
当然,floatingActionButton 属性主要用于 FloatingActionButton,但很高兴知道您可以在其中放置任何小部件(其他类型的按钮、行、列等)。要定位此小部件,您可以使用“floatingActionButtonLocation”脚手架属性。
| 归档时间: |
|
| 查看次数: |
11947 次 |
| 最近记录: |