简体   繁体   中英

SingleChildScrollView is not scrolling

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>[...],
                      ),
                    )
                  ],
                ),
              ),
            )
          ],
        ),
      )
    ],
  ),
);

}

It's solved. Idk the problem but I guess it's in relation to the hierarchy. When keep simple, It worked. Here is the new codes. Thanks for the help.

    @override
  Widget build(BuildContext context) {
    return Scaffold(
      resizeToAvoidBottomPadding: true,
      body: Stack(
        overflow: Overflow.visible,
        children: <Widget>[
          SingleChildScrollView(
            child: Padding(
              padding: EdgeInsets.only(top: ScreenUtil().setHeight(180)),
              child: Padding(
                padding: EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(40) ,),
                child: Container(
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[...],

                  ),
                ),
              ),
            ),
          ),
          Container(...),
          Align(
            alignment: Alignment.bottomCenter,
            child: Container(...)
        ],
      ),
    );
  }

Set resizeToAvoidBottomInset: true in Scaffold

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM