Flutter 如何在Flatter中的Appbar下添加文本字段
我正在尝试在我的绘画应用程序的顶部应用程序栏下添加一个文本字段,但我不知道如何添加。我试图在网上寻找解决方案,但没有找到任何Flutter 如何在Flatter中的Appbar下添加文本字段,flutter,flutter-layout,Flutter,Flutter Layout,我正在尝试在我的绘画应用程序的顶部应用程序栏下添加一个文本字段,但我不知道如何添加。我试图在网上寻找解决方案,但没有找到任何 @override Widget build(BuildContext context) { return Scaffold( appBar: new AppBar(title: new Center(child: new Text("Draw 1102 - Beta Version", textAlign: TextAlign.center)
@override
Widget build(BuildContext context)
{
return Scaffold(
appBar: new AppBar(title: new Center(child: new Text("Draw 1102 - Beta Version", textAlign: TextAlign.center))),
body:
Column(children: <Widget>[ TextField() ],), // Does not work
Container(
child: GestureDetector(
onPanUpdate: (DragUpdateDetails details)
{
setState(()
{
RenderBox _object = context.findRenderObject();
//More code...
});
},
@覆盖
小部件构建(构建上下文)
{
返回脚手架(
appBar:new appBar(标题:new Center(子项:新文本(“Draw 1102-Beta版”,textAlign:textAlign.Center)),
正文:
列(子项:[TextField()],),//不起作用
货柜(
儿童:手势检测器(
onPanUpdate:(DragUpdate详细信息)
{
设置状态()
{
RenderBox_object=context.findenderobject();
//更多代码。。。
});
},
您可以使用作为AppBars底部的属性。
PreferredSize小部件也有一个子部件,您可以在其中放置文本字段
您只需手动找到首选大小的正确高度。您可以使用a作为AppBars底部的属性。
PreferredSize小部件也有一个子部件,您可以在其中放置文本字段
您只需手动找到首选尺寸的正确高度。我得到的AppBar:-
appBar:appBar(
工具栏高度:110,//设置此高度
flexibleSpace:容器(
颜色:颜色,蓝色,
子项:列(子项:[
世界其他地区(儿童:[
尺寸箱(宽度:15),
图标(Icons.menu,颜色:Colors.white),
尺寸箱(宽度:10),
文本(“演示”,
样式:TextStyle(字体大小:23,颜色:Colors.white))
]),
尺寸箱(高度:8),
容器(
身高:40,
边缘:边缘组。对称(水平:20,垂直:5),
孩子:TextField(
textAlign:textAlign.center,
控制员:搜索,
装饰:输入装饰(
内容填充:
边缘组。对称(垂直:10,水平:10),
是的,
fillColor:Colors.white,
前缀:图标(Icons.search,颜色:Colors.black),
边框:大纲输入边框(
边界半径:
边界半径所有(半径圆形(40)),
hintStyle:新文本样式(颜色:Colors.black38),
hintText:“搜索”),
)),
]),
),
)
我得到的AppBar:-
appBar:appBar(
工具栏高度:110,//设置此高度
flexibleSpace:容器(
颜色:颜色,蓝色,
子项:列(子项:[
世界其他地区(儿童:[
尺寸箱(宽度:15),
图标(Icons.menu,颜色:Colors.white),
尺寸箱(宽度:10),
文本(“演示”,
样式:TextStyle(字体大小:23,颜色:Colors.white))
]),
尺寸箱(高度:8),
容器(
身高:40,
边缘:边缘组。对称(水平:20,垂直:5),
孩子:TextField(
textAlign:textAlign.center,
控制员:搜索,
装饰:输入装饰(
内容填充:
边缘组。对称(垂直:10,水平:10),
是的,
fillColor:Colors.white,
前缀:图标(Icons.search,颜色:Colors.black),
边框:大纲输入边框(
边界半径:
边界半径所有(半径圆形(40)),
hintStyle:新文本样式(颜色:Colors.black38),
hintText:“搜索”),
)),
]),
),
)
appBar: AppBar(
toolbarHeight: 110, // Set this height
flexibleSpace: Container(
color: Colors.blue,
child: Column(children: <Widget>[
Row(children: <Widget>[
SizedBox(width: 15),
Icon(Icons.menu, color: Colors.white),
SizedBox(width: 10),
Text("Demo",
style: TextStyle(fontSize: 23, color: Colors.white))
]),
SizedBox(height: 8),
Container(
height: 40,
margin: EdgeInsets.symmetric(horizontal: 20, vertical: 5),
child: TextField(
textAlign: TextAlign.center,
controller: search,
decoration: InputDecoration(
contentPadding:
EdgeInsets.symmetric(vertical: 10, horizontal: 10),
filled: true,
fillColor: Colors.white,
prefixIcon: Icon(Icons.search, color: Colors.black),
border: OutlineInputBorder(
borderRadius:
BorderRadius.all(Radius.circular(40))),
hintStyle: new TextStyle(color: Colors.black38),
hintText: "Search"),
)),
]),
),
)