SingleChildScrollView不滚动 [英] SingleChildScrollView is not scrolling

查看:841
本文介绍了SingleChildScrollView不滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当键盘出现但我没有滚动时,我正在尝试滚动表单.隐藏键盘时,没有溢出,只需要在键盘出现时滚动即可.

I'm trying to scroll the form when keyboard appears but it's not scrolling. While keyboard is hidden there is no overflow I need to scroll just when keyboard appeared.

Widget build(BuildContext context) {
return Scaffold(
  resizeToAvoidBottomInset: false,
  body: Stack(
    children: <Widget>[
      Container(
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            Container(...),
            SingleChildScrollView(
              child: Padding(
                padding: EdgeInsets.symmetric(
                    horizontal: ScreenUtil().setWidth(40)),
                child: Column(crossAxisAlignment: CrossAxisAlignment.start,

                  children: <Widget>[
                    Container(
                      alignment: Alignment.center,
                      child: Image(
                        image: AssetImage("assets/images/logoBrown.png"),
                        alignment: Alignment.center,
                        fit: BoxFit.cover,
                        height: ScreenUtil().setHeight(146),
                        width: ScreenUtil().setWidth(195),
                      ),
                    ),
                    Form(
                      child: Column(
                        children: <Widget>[...],
                      ),
                    )
                  ],
                ),
              ),
            )
          ],
        ),
      )
    ],
  ),
);

}

推荐答案

在脚手架中设置 resizeToAvoidBottomInset:true

  Widget build(BuildContext context) {
   return Scaffold(
   resizeToAvoidBottomInset: true,
   body: Stack(
     _ _ _ _
     _ _ _ _
     _ _ _ _
     _ _ _ _
    )

这篇关于SingleChildScrollView不滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆