首页 > 解决方案 > 单击 TextFormField 时隐藏在键盘后面

问题描述

我已经在其父是 SingleChildScrollView 的列中实现了 TextFormField。但不知何故,当我单击 TextFormField 时,它无法自动滚动。

有关更多详细信息,我正在添加视频 URL。视频

这是代码:

Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      resizeToAvoidBottomPadding: false,
      floatingActionButton: FloatingActionButton(
        backgroundColor: AppTheme.colors.themeBlue,
        child: Icon(Icons.arrow_forward),
        onPressed: () {

        },
      ),
      body: Container(
        color: AppTheme.colors.backgroundLight,
        child: Column(
          children: <Widget>[
            AppBarWidget(
              title: Constants.addClient,
            ),
            ProfileImageWidget(),
            Container(
                height: 100,
                width: screenSize.width,
                child: ListView(
                  padding: EdgeInsets.all(AppSize.small),
                  children: <Widget>[
                    SizedBox(
                      height: 10,
                    ),
                    ProfileTextFieldWidget(
                      labelTextStyle: AppTheme.textStyle.lightHeading
                          .copyWith(
                          fontSize: AppFontSize.s18,
                          color: AppTheme.colors.themeBlue),
                      labelText: Constants.clientName,
                      hintText: Constants.michaelNilson,
//                        cursorColor: AppTheme.colors.themeBlue,
                    ),
                    SizedBox(
                      height: 10,
                    ),
                    ProfileTextFieldWidget(
                      labelTextStyle: AppTheme.textStyle.lightHeading
                          .copyWith(
                          fontSize: AppFontSize.s18,
                          color: AppTheme.colors.themeBlue),
                      labelText: Constants.email,
                      hintText: Constants.email,
                      textInputAction: TextInputAction.done,
                    ),
                    SizedBox(
                      height: 10,
                    ),
                    ProfileTextFieldWidget(
                      labelTextStyle: AppTheme.textStyle.lightHeading
                          .copyWith(
                          fontSize: AppFontSize.s18,
                          color: AppTheme.colors.themeBlue),
                      labelText: Constants.mobile,
                      hintText: Constants.mobile,
                      textInputAction: TextInputAction.done,
                    ),
                    SizedBox(
                      height: 10,
                    ),
                    ProfileTextFieldWidget(
                      labelTextStyle: AppTheme.textStyle.lightHeading
                          .copyWith(
                          fontSize: AppFontSize.s18,
                          color: AppTheme.colors.themeBlue),
                      labelText: Constants.followUp,
                      hintText: Constants.followUp,
                      textInputAction: TextInputAction.done,
                      suffixIcon: IconButton(
                        icon: Icon(
                          Icons.keyboard_arrow_down,
                          color: Colors.black87,
                        ),
                      ),
                    ),
                    SizedBox(
                      height: 10,
                    ),
                    ProfileTextFieldWidget(
                      labelTextStyle: AppTheme.textStyle.lightHeading
                          .copyWith(
                          fontSize: AppFontSize.s18,
                          color: AppTheme.colors.themeBlue),
                      labelText: Constants.date,
                      suffixIcon: IconButton(
                        icon: Icon(
                          Icons.date_range,
                          size: 15,
                          color: Colors.black87,
                        ),
                      ),
                      hintText: Constants.date,
                      textInputAction: TextInputAction.done,
                    ),
                    SizedBox(
                      height: 10,
                    ),
                    ProfileTextFieldWidget(
                      labelTextStyle: AppTheme.textStyle.lightHeading
                          .copyWith(
                          fontSize: AppFontSize.s18,
                          color: AppTheme.colors.themeBlue),
                      suffixIcon: IconButton(
                        icon: Icon(
                          Icons.access_time,
                          size: AppSize.medium,
                          color: Colors.black87,
                        ),
                      ),
                      hintText: Constants.time,
                      labelText: Constants.time,
                      textInputAction: TextInputAction.done,
                    ),
                    SizedBox(
                      height: AppSize.small,
                    ),
                    ProfileTextFieldWidget(
                      labelTextStyle: AppTheme.textStyle.lightHeading
                          .copyWith(
                          fontSize: AppFontSize.s18,
                          color: AppTheme.colors.themeBlue),
                      labelText: Constants.notes,
                      hintText: Constants.notes,
                      textInputAction: TextInputAction.done,
                    ),
                    SizedBox(
                      height: AppSize.small,
                    ),
                  ],
                )
            )
          ],
        ),
      ),
    );
  }

详情请看视频:

标签: androidflutteruser-interfacedart

解决方案


立即删除resizeToAvoidBottomPadding: false,已弃用的

并使用 resizeToAvoidBottomInset: true,


推荐阅读