[英]Soft Keyboard covers TextInput on the SlidingUpPanel flutter
将panelBuilder
的内容包装在Scaffold
中,并且不要更改resizeToAvoidBottomInset
。 默认情况下,resize 为true
,这将向上移动内容以避免在出现时被键盘隐藏。 false
设置可防止发生调整大小。
下面的示例来自slide_up_panel package 示例,其中panelBuilder
参数结果包装在Scaffold
中。 (我不建议您像我在下面所做的那样包装_panel
,只是更容易显示以这种方式工作的示例。在_panel
function 本身中使用 Scaffold 可能会更好。)
@override
Widget build(BuildContext context){
_panelHeightOpen = MediaQuery.of(context).size.height * .80;
return Material(
child: Stack(
alignment: Alignment.topCenter,
children: <Widget>[
SlidingUpPanel(
maxHeight: _panelHeightOpen,
minHeight: _panelHeightClosed,
parallaxEnabled: true,
parallaxOffset: .5,
body: _body(),
// WRAP panel contents in Scaffold
panelBuilder: (sc) => Scaffold(body: _panel(sc)),
// ↑↑↑↑↑↑↑↑
borderRadius: BorderRadius.only(topLeft: Radius.circular(18.0), topRight: Radius.circular(18.0)),
onPanelSlide: (double pos) => setState((){
_fabHeight = pos * (_panelHeightOpen - _panelHeightClosed) + _initFabHeight;
}),
),
为了测试自己,将 TextFormField 添加到Widget _panel(ScrollController sc)
方法的底部(大约第 242 行)
SizedBox(height: 24,),
// ↓ Added for testing
TextFormField(
initialValue: 'type here',
onSaved: (txt) => null,
)
然后运行示例,向上滚动面板并点击 TextField 以使键盘向上滑动。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.