无法在listView中移动文本形式字段以调整到键盘

发布于 2025-01-26 11:52:39 字数 26051 浏览 2 评论 0原文

我遇到的问题是,在底部字段中,键盘覆盖了我正在使用的字段,因此我看不到我在这些图片中看到的内容:

作为一个示例,请参见名为的字段:“ cita”

“

,一旦选择:

“

最后是我的代码,其中是否有使这种行为发生的东西。

   Center(
                                    child: TextButton.icon(
                                        onPressed: () {
                                          showModalBottomSheet(
                                            context: context,
                                            isScrollControlled: true,
                                            enableDrag: true,
                                            elevation: 100,
                                            builder: (BuildContext context) {
                                              return StatefulBuilder(builder:
                                                  (context, modalSetState) {
                                                return Container(
                                                  padding: const EdgeInsets
                                                      .symmetric(
                                                    horizontal: 7,
                                                    vertical: 1,
                                                  ),
                                                  margin: const EdgeInsets.only(
                                                    left: 7,
                                                    right: 7,
                                                    top: 5,
                                                    bottom: 15,
                                                  ),
                                                  child: Form(
                                                    key: _form,
                                                    child: ListView(
                                                      shrinkWrap: true,
                                                      children: [
                                                        Padding(
                                                          padding:
                                                              const EdgeInsets
                                                                      .symmetric(
                                                                  vertical: 5),
                                                          child: Column(
                                                            crossAxisAlignment:
                                                                CrossAxisAlignment
                                                                    .center,
                                                            children: [
                                                              Text(
                                                                'Introdusca Detalles de Culto',
                                                                style:
                                                                    TextStyle(
                                                                  fontWeight:
                                                                      FontWeight
                                                                          .bold,
                                                                  fontSize: 20,
                                                                ),
                                                              ),
                                                              Divider(
                                                                color: Colors
                                                                    .black,
                                                                thickness: 1.00,
                                                              ),
                                                            ],
                                                          ),
                                                        ),
                                                        Padding(
                                                          padding:
                                                              const EdgeInsets
                                                                  .symmetric(
                                                            vertical: 5,
                                                            horizontal: 5,
                                                          ),
                                                          child: DateTimeField(
                                                            format: dateFormat,
                                                            style: TextStyle(
                                                              color:
                                                                  Colors.black,
                                                            ),
                                                            decoration:
                                                                InputDecoration(
                                                              labelText:
                                                                  'Fecha',
                                                              labelStyle:
                                                                  TextStyle(
                                                                color: Colors
                                                                    .black,
                                                                fontWeight:
                                                                    FontWeight
                                                                        .bold,
                                                              ),
                                                              enabledBorder:
                                                                  OutlineInputBorder(
                                                                borderSide:
                                                                    BorderSide(
                                                                  color: Colors
                                                                      .black,
                                                                ),
                                                              ),
                                                            ),
                                                            cursorColor:
                                                                Colors.black,
                                                            onShowPicker: (context,
                                                                currentValue) async {
                                                              final date =
                                                                  await showDatePicker(
                                                                context:
                                                                    context,
                                                                firstDate:
                                                                    DateTime(
                                                                        1900),
                                                                initialDate:
                                                                    currentValue ??
                                                                        DateTime
                                                                            .now(),
                                                                lastDate:
                                                                    DateTime(
                                                                        2100),
                                                              );
                                                              if (date !=
                                                                  null) {
                                                                final time =
                                                                    TimeOfDay(
                                                                        hour: 7,
                                                                        minute:
                                                                            0);
                                                                return DateTimeField
                                                                    .combine(
                                                                        date,
                                                                        time);
                                                              } else {
                                                                return currentValue;
                                                              }
                                                            },
                                                            validator: (value) {
                                                              if (value ==
                                                                  null) {
                                                                return 'Porfavor Introduzca una Fecha';
                                                              }
                                                              return null;
                                                            },
                                                            onSaved: (value) {
                                                              modalSetState(() {
                                                                fecha = value;
                                                              });
                                                            },
                                                          ),
                                                        ),
                                                        Padding(
                                                          padding:
                                                              const EdgeInsets
                                                                  .all(5),
                                                          child: TextFormField(
                                                            cursorColor:
                                                                Colors.black,
                                                            style: TextStyle(
                                                              color:
                                                                  Colors.black,
                                                            ),
                                                            //initialValue: _hasData ? street : null,
                                                            decoration:
                                                                InputDecoration(
                                                              labelText:
                                                                  'Horario',
                                                              labelStyle:
                                                                  TextStyle(
                                                                color: Colors
                                                                    .black,
                                                                fontWeight:
                                                                    FontWeight
                                                                        .bold,
                                                              ),
                                                              enabledBorder:
                                                                  OutlineInputBorder(
                                                                borderSide:
                                                                    BorderSide(
                                                                  color: Colors
                                                                      .black,
                                                                ),
                                                              ),
                                                            ),
                                                            // onFieldSubmitted: (_) {
                                                            //   FocusScope.of(context).requestFocus(_street2Focus);
                                                            // },
                                                            validator: (value) {
                                                              if (value
                                                                  .isEmpty) {
                                                                return 'Porfavor Introduzca un Horario';
                                                              }
                                                              return null;
                                                            },
                                                            onSaved: (value) {
                                                              modalSetState(() {
                                                                horario = value;
                                                              });
                                                            },
                                                          ),
                                                        ),
                                                        Padding(
                                                          padding:
                                                              const EdgeInsets
                                                                  .all(5),
                                                          child: TextFormField(
                                                            cursorColor:
                                                                Colors.black,
                                                            style: TextStyle(
                                                              color:
                                                                  Colors.black,
                                                            ),
                                                            //initialValue: _hasData ? street : null,
                                                            decoration:
                                                                InputDecoration(
                                                              labelText:
                                                                  'Pastor',
                                                              labelStyle:
                                                                  TextStyle(
                                                                color: Colors
                                                                    .black,
                                                                fontWeight:
                                                                    FontWeight
                                                                        .bold,
                                                              ),
                                                              enabledBorder:
                                                                  OutlineInputBorder(
                                                                borderSide:
                                                                    BorderSide(
                                                                  color: Colors
                                                                      .black,
                                                                ),
                                                              ),
                                                            ),
                                                            // onFieldSubmitted: (_) {
                                                            //   FocusScope.of(context).requestFocus(_street2Focus);
                                                            // },
                                                            validator: (value) {
                                                              if (value
                                                                  .isEmpty) {
                                                                return 'Porfavor Introduzca el nombre del Pastor';
                                                              }
                                                              return null;
                                                            },
                                                            onSaved: (value) {
                                                              modalSetState(() {
                                                                pastor = value;
                                                              });
                                                            },
                                                          ),
                                                        ),
                                                        Padding(
                                                          padding:
                                                              const EdgeInsets
                                                                  .all(5),
                                                          child: TextFormField(
                                                            cursorColor:
                                                                Colors.black,
                                                            style: TextStyle(
                                                              color:
                                                                  Colors.black,
                                                            ),
                                                            //initialValue: _hasData ? street : null,
                                                            decoration:
                                                                InputDecoration(
                                                              labelText:
                                                                  'Iglesia',
                                                              labelStyle:
                                                                  TextStyle(
                                                                color: Colors
                                                                    .black,
                                                                fontWeight:
                                                                    FontWeight
                                                                        .bold,
                                                              ),
                                                              enabledBorder:
                                                                  OutlineInputBorder(
                                                                borderSide:
                                                                    BorderSide(
                                                                  color: Colors
                                                                      .black,
                                                                ),
                                                              ),
                                                            ),
                                                            // onFieldSubmitted: (_) {
                                                            //   FocusScope.of(context).requestFocus(_street2Focus);
                                                            // },
                                                            validator: (value) {
                                                              if (value
                                                                  .isEmpty) {
                                                                return 'Porfavor Introduzca nombre de la Iglesia';
                                                              }
                                                              return null;
                                                            },
                                                            onSaved: (value) {
                                                              modalSetState(() {
                                                                iglesia = value;
                                                              });
                                                            },
                                                          ),
                                                        ),
                                                        Padding(
                                                          padding:
                                                              const EdgeInsets
                                                                  .all(5),
                                                          child: TextFormField(
                                                            cursorColor:
                                                                Colors.black,
                                                            style: TextStyle(
                                                              color:
                                                                  Colors.black,
                                                            ),
                                                            //initialValue: _hasData ? street : null,
                                                            decoration:
                                                                InputDecoration(
                                                              labelText: 'Cita',
                                                              labelStyle:
                                                                  TextStyle(
                                                                color: Colors
                                                                    .black,
                                                                fontWeight:
                                                                    FontWeight
                                                                        .bold,
                                                              ),
                                                              enabledBorder:
                                                                  OutlineInputBorder(
                                                                borderSide:
                                                                    BorderSide(
                                                                  color: Colors
                                                                      .black,
                                                                ),
                                                              ),
                                                            ),
                                                            // onFieldSubmitted: (_) {
                                                            //   FocusScope.of(context).requestFocus(_street2Focus);
                                                            // },
                                                            validator: (value) {
                                                              if (value
                                                                  .isEmpty) {
                                                                return 'Porfavor Introduzca la Cita Principal';
                                                              }
                                                              return null;
                                                            },
                                                            onSaved: (value) {
                                                              modalSetState(() {
                                                                cita = value;
                                                              });
                                                            },
                                                          ),
                                                        ),
                                                      ],
                                                    ),
                                                  ),
                                                );
                                              });
                                            },
                                          );

亲切的问候。

The problem that I'm having is that at the bottom Fields the keyboard covers the Fields which I'm working with so I can't see what I'm typing as you can see in these pictures:

As an example see the field called: "Cita"

Cita not cover

And once selected:

Cita Covered

Finally here is my code, is there something in it that is making this behavior happen.

   Center(
                                    child: TextButton.icon(
                                        onPressed: () {
                                          showModalBottomSheet(
                                            context: context,
                                            isScrollControlled: true,
                                            enableDrag: true,
                                            elevation: 100,
                                            builder: (BuildContext context) {
                                              return StatefulBuilder(builder:
                                                  (context, modalSetState) {
                                                return Container(
                                                  padding: const EdgeInsets
                                                      .symmetric(
                                                    horizontal: 7,
                                                    vertical: 1,
                                                  ),
                                                  margin: const EdgeInsets.only(
                                                    left: 7,
                                                    right: 7,
                                                    top: 5,
                                                    bottom: 15,
                                                  ),
                                                  child: Form(
                                                    key: _form,
                                                    child: ListView(
                                                      shrinkWrap: true,
                                                      children: [
                                                        Padding(
                                                          padding:
                                                              const EdgeInsets
                                                                      .symmetric(
                                                                  vertical: 5),
                                                          child: Column(
                                                            crossAxisAlignment:
                                                                CrossAxisAlignment
                                                                    .center,
                                                            children: [
                                                              Text(
                                                                'Introdusca Detalles de Culto',
                                                                style:
                                                                    TextStyle(
                                                                  fontWeight:
                                                                      FontWeight
                                                                          .bold,
                                                                  fontSize: 20,
                                                                ),
                                                              ),
                                                              Divider(
                                                                color: Colors
                                                                    .black,
                                                                thickness: 1.00,
                                                              ),
                                                            ],
                                                          ),
                                                        ),
                                                        Padding(
                                                          padding:
                                                              const EdgeInsets
                                                                  .symmetric(
                                                            vertical: 5,
                                                            horizontal: 5,
                                                          ),
                                                          child: DateTimeField(
                                                            format: dateFormat,
                                                            style: TextStyle(
                                                              color:
                                                                  Colors.black,
                                                            ),
                                                            decoration:
                                                                InputDecoration(
                                                              labelText:
                                                                  'Fecha',
                                                              labelStyle:
                                                                  TextStyle(
                                                                color: Colors
                                                                    .black,
                                                                fontWeight:
                                                                    FontWeight
                                                                        .bold,
                                                              ),
                                                              enabledBorder:
                                                                  OutlineInputBorder(
                                                                borderSide:
                                                                    BorderSide(
                                                                  color: Colors
                                                                      .black,
                                                                ),
                                                              ),
                                                            ),
                                                            cursorColor:
                                                                Colors.black,
                                                            onShowPicker: (context,
                                                                currentValue) async {
                                                              final date =
                                                                  await showDatePicker(
                                                                context:
                                                                    context,
                                                                firstDate:
                                                                    DateTime(
                                                                        1900),
                                                                initialDate:
                                                                    currentValue ??
                                                                        DateTime
                                                                            .now(),
                                                                lastDate:
                                                                    DateTime(
                                                                        2100),
                                                              );
                                                              if (date !=
                                                                  null) {
                                                                final time =
                                                                    TimeOfDay(
                                                                        hour: 7,
                                                                        minute:
                                                                            0);
                                                                return DateTimeField
                                                                    .combine(
                                                                        date,
                                                                        time);
                                                              } else {
                                                                return currentValue;
                                                              }
                                                            },
                                                            validator: (value) {
                                                              if (value ==
                                                                  null) {
                                                                return 'Porfavor Introduzca una Fecha';
                                                              }
                                                              return null;
                                                            },
                                                            onSaved: (value) {
                                                              modalSetState(() {
                                                                fecha = value;
                                                              });
                                                            },
                                                          ),
                                                        ),
                                                        Padding(
                                                          padding:
                                                              const EdgeInsets
                                                                  .all(5),
                                                          child: TextFormField(
                                                            cursorColor:
                                                                Colors.black,
                                                            style: TextStyle(
                                                              color:
                                                                  Colors.black,
                                                            ),
                                                            //initialValue: _hasData ? street : null,
                                                            decoration:
                                                                InputDecoration(
                                                              labelText:
                                                                  'Horario',
                                                              labelStyle:
                                                                  TextStyle(
                                                                color: Colors
                                                                    .black,
                                                                fontWeight:
                                                                    FontWeight
                                                                        .bold,
                                                              ),
                                                              enabledBorder:
                                                                  OutlineInputBorder(
                                                                borderSide:
                                                                    BorderSide(
                                                                  color: Colors
                                                                      .black,
                                                                ),
                                                              ),
                                                            ),
                                                            // onFieldSubmitted: (_) {
                                                            //   FocusScope.of(context).requestFocus(_street2Focus);
                                                            // },
                                                            validator: (value) {
                                                              if (value
                                                                  .isEmpty) {
                                                                return 'Porfavor Introduzca un Horario';
                                                              }
                                                              return null;
                                                            },
                                                            onSaved: (value) {
                                                              modalSetState(() {
                                                                horario = value;
                                                              });
                                                            },
                                                          ),
                                                        ),
                                                        Padding(
                                                          padding:
                                                              const EdgeInsets
                                                                  .all(5),
                                                          child: TextFormField(
                                                            cursorColor:
                                                                Colors.black,
                                                            style: TextStyle(
                                                              color:
                                                                  Colors.black,
                                                            ),
                                                            //initialValue: _hasData ? street : null,
                                                            decoration:
                                                                InputDecoration(
                                                              labelText:
                                                                  'Pastor',
                                                              labelStyle:
                                                                  TextStyle(
                                                                color: Colors
                                                                    .black,
                                                                fontWeight:
                                                                    FontWeight
                                                                        .bold,
                                                              ),
                                                              enabledBorder:
                                                                  OutlineInputBorder(
                                                                borderSide:
                                                                    BorderSide(
                                                                  color: Colors
                                                                      .black,
                                                                ),
                                                              ),
                                                            ),
                                                            // onFieldSubmitted: (_) {
                                                            //   FocusScope.of(context).requestFocus(_street2Focus);
                                                            // },
                                                            validator: (value) {
                                                              if (value
                                                                  .isEmpty) {
                                                                return 'Porfavor Introduzca el nombre del Pastor';
                                                              }
                                                              return null;
                                                            },
                                                            onSaved: (value) {
                                                              modalSetState(() {
                                                                pastor = value;
                                                              });
                                                            },
                                                          ),
                                                        ),
                                                        Padding(
                                                          padding:
                                                              const EdgeInsets
                                                                  .all(5),
                                                          child: TextFormField(
                                                            cursorColor:
                                                                Colors.black,
                                                            style: TextStyle(
                                                              color:
                                                                  Colors.black,
                                                            ),
                                                            //initialValue: _hasData ? street : null,
                                                            decoration:
                                                                InputDecoration(
                                                              labelText:
                                                                  'Iglesia',
                                                              labelStyle:
                                                                  TextStyle(
                                                                color: Colors
                                                                    .black,
                                                                fontWeight:
                                                                    FontWeight
                                                                        .bold,
                                                              ),
                                                              enabledBorder:
                                                                  OutlineInputBorder(
                                                                borderSide:
                                                                    BorderSide(
                                                                  color: Colors
                                                                      .black,
                                                                ),
                                                              ),
                                                            ),
                                                            // onFieldSubmitted: (_) {
                                                            //   FocusScope.of(context).requestFocus(_street2Focus);
                                                            // },
                                                            validator: (value) {
                                                              if (value
                                                                  .isEmpty) {
                                                                return 'Porfavor Introduzca nombre de la Iglesia';
                                                              }
                                                              return null;
                                                            },
                                                            onSaved: (value) {
                                                              modalSetState(() {
                                                                iglesia = value;
                                                              });
                                                            },
                                                          ),
                                                        ),
                                                        Padding(
                                                          padding:
                                                              const EdgeInsets
                                                                  .all(5),
                                                          child: TextFormField(
                                                            cursorColor:
                                                                Colors.black,
                                                            style: TextStyle(
                                                              color:
                                                                  Colors.black,
                                                            ),
                                                            //initialValue: _hasData ? street : null,
                                                            decoration:
                                                                InputDecoration(
                                                              labelText: 'Cita',
                                                              labelStyle:
                                                                  TextStyle(
                                                                color: Colors
                                                                    .black,
                                                                fontWeight:
                                                                    FontWeight
                                                                        .bold,
                                                              ),
                                                              enabledBorder:
                                                                  OutlineInputBorder(
                                                                borderSide:
                                                                    BorderSide(
                                                                  color: Colors
                                                                      .black,
                                                                ),
                                                              ),
                                                            ),
                                                            // onFieldSubmitted: (_) {
                                                            //   FocusScope.of(context).requestFocus(_street2Focus);
                                                            // },
                                                            validator: (value) {
                                                              if (value
                                                                  .isEmpty) {
                                                                return 'Porfavor Introduzca la Cita Principal';
                                                              }
                                                              return null;
                                                            },
                                                            onSaved: (value) {
                                                              modalSetState(() {
                                                                cita = value;
                                                              });
                                                            },
                                                          ),
                                                        ),
                                                      ],
                                                    ),
                                                  ),
                                                );
                                              });
                                            },
                                          );

Kind Regards.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦与时光遇 2025-02-02 11:52:39


resizetoavoidbottominset:true,
作为参数
脚手架();中,

这将有助于当出现键盘时将Textfield向上推。

Give
resizeToAvoidBottomInset: true,
as argument
in Scaffold();

This will help to push the textfield upwards when keyboard appears.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文