[英]How to move textfields above a button which moves up with keyboard in flutter
我有一個與屏幕底部對齊的按鈕,這樣每當鍵盤打開時,按鈕將保持在鍵盤上方的位置。 此按鈕隱藏包含在 singlechildscrollview 中的列中的文本字段。
(TextFields 隨鍵盤向上移動。在列上方堆疊的 Botton 是導致問題的原因)
我嘗試在 Padding 小部件中包裝列並給出底部填充,但結果仍然相同。 請建議一種將文本字段放置在按鈕上方的方法。
注:第一次海報。 如有錯誤請見諒。 謝謝你
return SafeArea(
child: Stack(
fit: StackFit.expand,
children: [
SingleChildScrollView(
child: Container(
child: Column(
children: [
Container(
color: Colors.deepOrange,
width: double.maxFinite,
height: height * 0.3,
),
Container(
color: Colors.black,
width: double.maxFinite,
height: height * 0.56,
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Utils().colSpacer20,
TextBox(hint: "name", editingController: _controller),
Utils().colSpacer20,
TextBox(hint: "name", editingController: _controller),
Utils().colSpacer20,
TextBox(hint: "name", editingController: _controller),
Utils().colSpacer20,
TextBox(hint: "name", editingController: _controller),
Utils().colSpacer20,
TextBox(hint: "name", editingController: _controller)
],
),
),
),
],
),
),
),
Positioned(
bottom: 0,
left: 0,
right: 0,
child: FlatButton(
color: Colors.blue[900],
onPressed: () {},
child: Text(
"Save",
style: TextStyles().subTextStyleWhite,
),
minWidth: double.maxFinite,
height: height * 0.1,
),
)
],
),
);
編輯:TextField 小部件的 scrollPadding 屬性解決了這個問題。 謝謝@Anitesh Reddy。
將 padding/margin 或 sizedBox( height:height*0.12 ) 保留在列的底部,以便定位的小部件將向下移動並留出空間。
使用滾動填充屬性
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.