简体   繁体   English

Textfeild 的键盘在 Flutter v2 中隐藏底页

[英]Textfeild's keyboard hide bottomsheet in Flutter v2

Why my bottomsheet is disappearing upon opening keyboard while clicking textfeild ?为什么在单击bottomsheet时打开键盘时我的底页消失textfeild I tried many solutions but none of them is working properly.我尝试了许多解决方案,但没有一个能正常工作。

I have nothing much to add just trying to complete the words criteria.我没有什么要补充的,只是试图完成单词标准。 "It looks like your post is mostly code; please add some more details". “看起来您的帖子主要是代码;请添加更多详细信息”。

Container(
     padding: EdgeInsets.symmetric(
     horizontal: deviceSize.width * 0.1),
          child: InkWell(
              onTap: () {
                  showAddressBottomSheet(context);
              },
                child: ...// Button style
           ),
 void showAddressBottomSheet(BuildContext _context) {
    showModalBottomSheet(
      backgroundColor: Colors.transparent,
      context: _context,
      isScrollControlled: true,
      elevation: 20,
      builder: (context) {
        return AddAddressView(
          callback: (val) => setState(() => _addrSelectedTitle = val),
        );
      },
    );
  }

Actual Buttom sheet实际底板

class AddAddressView extends StatefulWidget {
  @override
  _AddAddressViewState createState() => _AddAddressViewState();
}

class _AddAddressViewState extends State<AddAddressView> {
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
         child: Container(
            padding: EdgeInsets.all(30),
               child: ListView(
                  shrinkWrap: true,
                  children: <Widget>[
                    Text(......),
                    TextField(
                        autofocus: true,
                        style: TextStyle(fontSize:15),
                        controller: widget.controller,
                        ..........
                     ),
                   ),
                 ),
               ),
             },
          }

在此处输入图像描述

I have seen this issue before and since you have posted a reproduction of your actual code, I'm assuming this padding value exists somewhere in your widget tree我以前见过这个问题,因为你已经发布了你的实际代码的复制品,我假设这个填充值存在于你的小部件树的某个地方

padding: EdgeInsets.only(
          bottom: MediaQuery.of(context).viewInsets.bottom,
        ),

In older versions of flutter, this padding was required for the bottom sheet to move up when the keyboard is in view.在旧版本的 flutter 中,当键盘在视图中时,底部面板需要此填充才能向上移动。 They have however been fixed and you don't need to apply the padding anymore and the framework will handle it.然而,它们已被修复,您不再需要应用填充,框架将处理它。 Otherwise there will be twice as much padding as seen in your case.否则,填充量将是您的情况的两倍。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM