【发布时间】:2020-07-12 23:28:41
【问题描述】:
我是新来的颤振。我被困在一个地方,找不到确切的解决方案。
我有一个 BottomNavigationBar,其中有一个需要用户输入的文本字段。当我点击文本字段时,键盘覆盖了整个半屏,文本字段隐藏在键盘后面,看不到。我想将文本字段移到键盘上方,以便为用户提供更好的 UI。
这是底部导航条代码:
Widget build(BuildContext context) {
return Container(
color: Colors.grey[200],
height: 70,
child: Row(
children: <Widget>[
SizedBox(
height: MediaQuery.of(context).viewInsets.bottom,
),
Container(
width: MediaQuery.of(context).size.width * 0.6,
color: Colors.transparent,
margin: EdgeInsets.fromLTRB(40, 0, 0, 0),
child: TextField( //this is the TextField
style: TextStyle(
fontSize: 30,
fontFamily: 'Karla',
),
decoration: InputDecoration.collapsed(
hintText: 'Experimez-vous...',
hintStyle: TextStyle(color: Colors.black),
),
),
),
],
),
);
这是主体(脚手架)我从以下位置调用它:
return Scaffold(
body: Column(
children: <Widget>[
CloseButtonScreen(),
Container(
color: Colors.transparent,
child: HeaderContent(),
),
ContainerListItems(),
],
),
bottomNavigationBar: BottomNavBar(), //this is where Im calling my BottomNavigationBar from
floatingActionButton: FloatingActionBtn(),
floatingActionButtonLocation: FloatingActionButtonLocation.endDocked,
resizeToAvoidBottomPadding: false,
);
截图:
文本字段位于底部导航栏中的键盘后面
体验一下 texfield
【问题讨论】:
-
可以分享完整的代码吗?
-
这是完整的代码兄弟。我已共享用于解决我所面临的特定问题的所有文件。
标签: android user-interface flutter dart hidden-field