使用手机键盘时颤抖,文本框被隐藏

问题描述 投票:1回答:1

由于用户看不到他在写什么,这是它的外观,因此电话键盘妨碍了用户必须输入的文本框的方式

这是没有键盘的屏幕Phone screen without keyboard

这是带有键盘的屏幕

Phone screen with keyboard

这是我当前的文本字段代码

TextFormField(
                      initialValue: '',
                      onChanged: (text) {
                        messageEntered = text;
                      },
                      style: TextStyle(color: Colors.white),
                      decoration: InputDecoration(
                          labelText:
                              Translations.of(context).trans('message'),
                          fillColor: Colors.white,
                          labelStyle: TextStyle(color: Colors.white)),
                    ),

反正有防止这种情况发生的方法吗?谢谢您的时间

编辑:这是我的页面代码,其中的脚手架已经包装好

return showDialog(
    barrierDismissible: false,
    context: context,
    builder: (BuildContext context) {
      return StatefulBuilder(builder: (context, setState) {
        return WillPopScope(
            onWillPop: () {
              return Future.value(true);
            },
            child: Scaffold(
                  resizeToAvoidBottomPadding: false, 
              body: Container(
                color: Colors.red,
                padding: const EdgeInsets.all(16.0),
                width: double.infinity,
                height: double.infinity,
                child: Column(
                  children: <Widget>[
                    Container(height: 30),
                    new Text(
                      Translations.of(context).trans('sendmessage'),
                      style: TextStyle(color: Colors.white),
                    ),
                    Container(
                      height: 30,
                    ),
                    DropdownButton(
                      focusColor: Colors.white,
                      hint: new Text(
                        Translations.of(context).trans('sendto'),
                        style: TextStyle(color: Colors.white),
                      ),
                      isExpanded: true,
                      onChanged: (value) {
                        setState(() => selected = value);
                        setState(() => toEntered = selected);
                      },
                      value: selected,
                      items: workers.map((worker) {
                        return DropdownMenuItem(
                          child: new Text(worker.vNome),
                          value: worker.vCodigo,
                        );
                      }).toList(),
                    ),
                    Container(
                      height: 30,
                    ),
                    TextFormField(
                        initialValue: date,
                        onChanged: (text) {
                          dateEntered = text;
                        },
                        style: TextStyle(color: Colors.white),
                        decoration: InputDecoration(
                            labelText:
                                Translations.of(context).trans('date'),
                            fillColor: Colors.white,
                            labelStyle: TextStyle(color: Colors.white))),
                    Container(
                      height: 30,
                    ),
                    TextFormField(
                        initialValue: hour,
                        onChanged: (text) {
                          hourEntered = text;
                        },
                        style: TextStyle(color: Colors.white),
                        decoration: InputDecoration(
                            labelText:
                                Translations.of(context).trans('hour'),
                            fillColor: Colors.white,
                            labelStyle: TextStyle(color: Colors.white))),
                    Container(
                      height: 30,
                    ),
                    TextFormField(
                      initialValue: '',
                      onChanged: (text) {
                        messageEntered = text;
                      },
                      style: TextStyle(color: Colors.white),
                      decoration: InputDecoration(
                          labelText:
                              Translations.of(context).trans('message'),
                          fillColor: Colors.white,
                          labelStyle: TextStyle(color: Colors.white)),
                    ),
                    Spacer(),
                    Row(
                      children: <Widget>[
                        FlatButton(
                            textColor: Colors.white,
                            color: Colors.red[800],
                            child: Text(Translations.of(context)
                                .trans('sendmessage')),
                            onPressed: () {
                              sendMessage();
                            }),
                        Spacer(),
                        FlatButton(
                            textColor: Colors.white,
                            color: Colors.red[800],
                            child: Text(Translations.of(context)
                                .trans('closealert')),
                            onPressed: () {
                              setState(() => selected = null);
                              Navigator.of(context).pop();
                            }),
                      ],
                    ),
                  ],
                ),
              ),
            ));
      });
    });
flutter textfield android-softkeyboard
1个回答
0
投票

尝试一下,我添加了TODO

© www.soinside.com 2019 - 2024. All rights reserved.