flutter - Flutter TextFormField 在键盘出现时隐藏
问题描述
我是颤振的新手,我有一个问题。当我单击 textformField 时,这个消失了
我将容器放入红色,但通常它是透明的
我放了一个堆栈,然后在后台扩展了 GoogleMap。为了产生研究效果,我在 textformfield 上放置了一个叠加层,我将使用特定的过滤器按钮而不是黄色和绿色。
问题是,当我单击 textformfield 时,它会从屏幕上消失。我尝试使用 SingleChildScrollView、ListView,但我仍然有错误,特别是因为 GoogleMap 占用了所有空间所有内容都包含在 Scaffold 中
你能帮我吗,在哪里给我一个解决方案?我附上下面的代码
亲切地
return Stack( children: [ /// GoogleMap Column( children: [ Expanded( child: GoogleMap(initialCameraPosition: _kInitialPosition), ), ], ),
/// Search Bar And Filter
Positioned.fill(
bottom: _searchBarContainer,
child: SafeArea(
child: Container(
color: Colors.red,
child: Padding(
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
child: Row(
children: [
/// Search Bar
Expanded(
child: TextFormField(
decoration: DesignWidget.inputDecorationTexFieldMap(
_searchBarMap, Icons.search),
),
),
/// Filter
Container(
width: _filterContainer,
color: Colors.green,
child: Row(
children: [
Container(
color: Colors.yellow,
width: _filterContainer / 2,
),
Container(
color: Colors.green,
width: _filterContainer / 2,
)
],
),
),
],
),
),
),
),
),
],
);
解决方案
我认为在使用 textFormField 之前,您必须定义一个键或控制器.....当您没有定义控制器实例并在 textFormField 控制器内部使用该控制器时,就会发生这种情况。
推荐阅读
- maven - 对于包含客户端代码的模块,建议使用什么命名约定?
- windows - 卸载 VS Code 会删除我的设置吗?
- c# - 使用存储在同一目录中的多个 exe 文件的软件应该如何处理
- go - 在循环中清除和重写切片
- powershell - Powershell get-server - 排除列表中的那些
- reactjs - 基于 redux/react 的容器的可重用性
- vba - Range.End 空白 VBA
- git - 如何在 vs code 中设置 Team Foundation Server 存储库?
- typescript - 错误类型没有编译错误
- sql - 不以元音开头,也不以元音结尾