【发布时间】:2023-01-16 17:31:46
【问题描述】:
我正在尝试在 flutter 上创建一个如下所示的聊天页面:top bar + bottom textField and send button。我已经能够使用发送按钮制作顶部应用栏和文本字段,但我无法成功地将文本字段定位在页面底部。我尝试过对齐和展开、页脚、BottomNavigationBar 之类的东西。
我粘贴的代码的当前版本仅显示顶部的 Appbar。如果我取出子行和发送按钮,我在页面底部有一个文本字段。出于某种原因,一旦我添加子行以便能够添加发送按钮,整个文本字段就不会显示在屏幕上。我将不胜感激任何帮助。
注意:因为我正在尝试制作一个聊天屏幕,所以我希望中间部分可以滚动(同时保留顶部和底部),稍后我可以在其中添加聊天气泡。
Screenshot of code because of the bad editing of code snippet Continuation of code snippet
“”“
@覆盖
小部件构建(BuildContext 上下文){
返回脚手架(
背景颜色:ColorConstant.whiteA700,
// 顶栏
应用栏:应用栏(
背景颜色:ColorConstant.deepOrange300,
title: Text("匹配名称",style: AppStyle.textstyleinterregular15.copyWith(
字体大小:getFontSize(15))),
),
body: Column(
children: [
Expanded(child: SingleChildScrollView(
child: Column(
children: [
// Bubbles
],
),
),
),
Container(
height: 45,
width: double.infinity,
color: ColorConstant.whiteA700,
child: Row(children: <Widget>[
TextField(
decoration: InputDecoration(
hintText: "Message...",
hintStyle: TextStyle(color: ColorConstant.bluegray100),
border: OutlineInputBorder(
borderSide: BorderSide(color: ColorConstant.bluegray100)
),
)
),
SizedBox(width: 15,),
// Send Button
FloatingActionButton(
onPressed: (){},
child: Icon(Icons.send,color: ColorConstant.whiteA700,size: 18,),
backgroundColor: ColorConstant.lightBlueA100,
elevation: 0,
),
]),
);
],
),
);
“”“
【问题讨论】: