【发布时间】:2021-10-05 16:24:50
【问题描述】:
【问题讨论】:
标签: flutter dart mobile frontend
【问题讨论】:
标签: flutter dart mobile frontend
在第二个选项卡中,您应该使用 Column() 小部件并应用 mainAxixAlignment:MainAxisAlignment.end
或者您可以执行以下代码,
Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Header(),//optional if you have anything show above messages
Expanded(
child: SingleChildScrollView(
reverse: true,
padding: EdgeInsets.only(bottom: 10),
child: Column(
children: messages, //here is the messaging part
), //
),
),
Bottom(),//here the key board part goes
],)
在这段代码中,我们用扩展包装消息,因此它将占据所有可用空间并推到底部,即使expanded 使用的空间比屏幕少,spacebetween 也会推到底部。
【讨论】:
你可以像这样使用Scaffold的bottomSheet参数
Scaffold(
backgroundColor: Colors.white,
bottomSheet: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: MediaQuery.of(context).size.width - 120,
height: 45,
child: TextField(
decoration: InputDecoration(
isDense: true,
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(30),
borderSide: BorderSide(color: Colors.grey),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(30),
borderSide: BorderSide(color: Colors.grey),
),
),
),
),
TextButton(
onPressed: () {},
child: Text('press'),
),
],
),
body: Container(),
);
您可以通过单击选项卡来隐藏和显示此 bottomSheet 小部件
【讨论】: