Flutter SinglechildScrollview无法正常工作

发布于 2025-01-26 23:45:22 字数 3362 浏览 3 评论 0原文

我希望打开键盘时滚动页面可以工作,但是当打开键盘时它不起作用,用户需要查看他的键入内容,我正在制作登录页面,当键盘打开时,ScrollView将工作,我在另一个项目中使用了相同的代码,但是它在那里工作,它在我的项目中不起作用,这可能是什么原因?
编辑:我想做的是,当键盘弹出时,我应该能够滚动屏幕

我的代码:

Scaffold(
      resizeToAvoidBottomInset: true,
      body: Stack(
        children: [
          SafeArea(
            child: SingleChildScrollView(
              controller: scrollController,
              child: Container(
                padding: MediaQuery.of(context).size.width > webScreenSize
                    ? EdgeInsets.symmetric(
                        horizontal: MediaQuery.of(context).size.width / 3)
                    : const EdgeInsets.symmetric(
                        horizontal: 15,
                      ),
                height: deviceHeight,
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    Padding(
                      padding: const EdgeInsets.only(top: 35.0),
                      child: SvgPicture.asset(
                        "assets/bahce.svg",
                        color: primaryColor,
                        height: 64.0,
                      ),
                    ),
                    Container(
                      height: deviceHeight * 0.65,
                      width: double.infinity,
                      margin: EdgeInsets.symmetric(horizontal: 20),
                      child: LayoutBuilder(
                        builder: (ctx, contsraints) {
                          return Column(
                            mainAxisAlignment: MainAxisAlignment.center,
                            children: [
                              SizedBox(
                                height: contsraints.maxHeight * 0.01,
                              ),
                              Container(
                                .......
                              ),
                              SizedBox(
                                height: contsraints.maxHeight * 0.05,
                              ),
                              Container(
                                height: contsraints.maxHeight * 0.12,
                               ...................
                              ),
                              Container(
                                width: double.infinity,
                                height: contsraints.maxHeight * 0.12,
                               ......button
                              ),
                              SizedBox(
                                height: contsraints.maxHeight * 0.15,
                              ),
                              RichText(
                                text: TextSpan(
                                  ......,
                                  children: [
                                    TextSpan(
                                      
                                        ..onTap = navigateToSignup,
                                    ),
                                  ],
                                ),
                              ),
                            ],
                          );
                        },
                      ),
                    ),
                  ],
                ),
              ),
            ),
          ),
        ],
      ),
    );

I want the scroll page to work when the keyboard is opened, but it does not work when the keyboard is opened, the user needs to see what he is typing, I am making a login page, when the keyboard opens, the scrollview will work, I used the same code in my other project, but it works there, it just does not work in my project, what could be the reason for this?
Edit: What I want to do is, when the keyboard pops up, I should be able to scroll the screen

My Code:

Scaffold(
      resizeToAvoidBottomInset: true,
      body: Stack(
        children: [
          SafeArea(
            child: SingleChildScrollView(
              controller: scrollController,
              child: Container(
                padding: MediaQuery.of(context).size.width > webScreenSize
                    ? EdgeInsets.symmetric(
                        horizontal: MediaQuery.of(context).size.width / 3)
                    : const EdgeInsets.symmetric(
                        horizontal: 15,
                      ),
                height: deviceHeight,
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    Padding(
                      padding: const EdgeInsets.only(top: 35.0),
                      child: SvgPicture.asset(
                        "assets/bahce.svg",
                        color: primaryColor,
                        height: 64.0,
                      ),
                    ),
                    Container(
                      height: deviceHeight * 0.65,
                      width: double.infinity,
                      margin: EdgeInsets.symmetric(horizontal: 20),
                      child: LayoutBuilder(
                        builder: (ctx, contsraints) {
                          return Column(
                            mainAxisAlignment: MainAxisAlignment.center,
                            children: [
                              SizedBox(
                                height: contsraints.maxHeight * 0.01,
                              ),
                              Container(
                                .......
                              ),
                              SizedBox(
                                height: contsraints.maxHeight * 0.05,
                              ),
                              Container(
                                height: contsraints.maxHeight * 0.12,
                               ...................
                              ),
                              Container(
                                width: double.infinity,
                                height: contsraints.maxHeight * 0.12,
                               ......button
                              ),
                              SizedBox(
                                height: contsraints.maxHeight * 0.15,
                              ),
                              RichText(
                                text: TextSpan(
                                  ......,
                                  children: [
                                    TextSpan(
                                      
                                        ..onTap = navigateToSignup,
                                    ),
                                  ],
                                ),
                              ),
                            ],
                          );
                        },
                      ),
                    ),
                  ],
                ),
              ),
            ),
          ),
        ],
      ),
    );

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

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

发布评论

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

评论(1

欲拥i 2025-02-02 23:45:22

直接删除其他韦德格人作为身体的孩子

Remove other widgers directly use sigle child scroll view as a child of body

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