Scrolling just a specific container

scroll snap
overflow: scroll not working
scroll-snap-stop
scroll-snap-type not working
scroll-snap-align
hide scrollbar css
css overflow-y
css scroll snap carousel

I have the following screen and I need the image area to be fixed and the form part to be scrollable when the keyboard opens:

Why the scrolling isn't working for the form part? I tried both with ListView and SingleChildScrollView, but it only works if I wrap the entire content (image and form) with it.

import 'package:ahgora/models/user.dart';
import 'package:flutter/material.dart';

class Home extends StatefulWidget {
  @override
  _HomeState createState() => _HomeState();
}

class _HomeState extends State<Home> {
  final _user = User();
  final _formKey = GlobalKey<FormState>();
  final _tokenNode = FocusNode();
  final _userNode = FocusNode();
  final _passwordNode = FocusNode();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        child: Builder(
          builder: (context) => Form(
            key: _formKey,
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.center,
              children: <Widget>[
                Container(
                  child: Image.asset("assets/images/logo.jpg",
                      fit: BoxFit.scaleDown,
                      width: 160,
                      alignment: Alignment.center),
                  margin: EdgeInsets.only(top: 100.0),
                ),
                ListView(shrinkWrap: true, children: <Widget>[
                      Container(
                        margin: EdgeInsets.all(20.0),
                        child: TextFormField(
                          textInputAction: TextInputAction.next,
                          focusNode: _tokenNode,
                          onFieldSubmitted: (term) {
                            _fieldFocusChange(context, _tokenNode, _userNode);
                          },
                          decoration: InputDecoration(
                            border: OutlineInputBorder(),
                            labelText: 'Chave ',
                          ),
                        ),
                      ),
                      Container(
                        margin: EdgeInsets.all(20.0),
                        child: TextFormField(
                          textInputAction: TextInputAction.next,
                          focusNode: _userNode,
                          onFieldSubmitted: (term) {
                            _fieldFocusChange(
                                context, _userNode, _passwordNode);
                          },
                          decoration: InputDecoration(
                              border: OutlineInputBorder(),
                              labelText: 'Usuário'),
                        ),
                      ),
                      Container(
                        margin: EdgeInsets.all(20.0),
                        child: TextFormField(
                          textInputAction: TextInputAction.next,
                          focusNode: _passwordNode,
                          decoration: InputDecoration(
                              border: OutlineInputBorder(), labelText: 'Senha'),
                        ),
                      ),
                      Container(
                        margin: EdgeInsets.all(20.0),
                        child: MaterialButton(
                          color: Colors.redAccent,
                          textColor: Colors.white,
                          onPressed: () => {},
                          child: Text('Registrar'),
                        ),
                      )
                    ]),
              ],
            ),
          ),
        ),
      ),
    );
  }

  _fieldFocusChange(
      BuildContext context, FocusNode currentFocus, FocusNode nextFocus) {
    currentFocus.unfocus();
    FocusScope.of(context).requestFocus(nextFocus);
  }
}

I made small change, if feasible please try this.

        class Home extends StatefulWidget {
        @override
        _HomeState createState() => _HomeState();
        }

        class _HomeState extends State<Home> {

        final _formKey = GlobalKey<FormState>();
        final _tokenNode = FocusNode();
        final _userNode = FocusNode();
        final _passwordNode = FocusNode();

        @override
        Widget build(BuildContext context) {
            return Scaffold(
            resizeToAvoidBottomInset: true,
            body: Container(
                child: Builder(
                builder: (context) => Form(
                    key: _formKey,
                    child: SingleChildScrollView(
                    child: Column(
                        crossAxisAlignment: CrossAxisAlignment.center,
                        children: <Widget>[
                        Container(
                            child: Image.network("http://www.militaryzone.eu/www/ir/produkt-images/108561-image0--mm344x300.jpg",
                                fit: BoxFit.scaleDown,
                                width: 160,
                                alignment: Alignment.center),
                            margin: EdgeInsets.only(top: 100.0),
                        ),

                            Container(
                            margin: EdgeInsets.all(20.0),
                            child: TextFormField(
                                textInputAction: TextInputAction.next,
                                focusNode: _tokenNode,
                                onFieldSubmitted: (term) {
                                _fieldFocusChange(context, _tokenNode, _userNode);
                                },
                                decoration: InputDecoration(
                                border: OutlineInputBorder(),
                                labelText: 'Chave ',
                                ),
                            ),
                            ),
                            Container(
                            margin: EdgeInsets.all(20.0),
                            child: TextFormField(
                                textInputAction: TextInputAction.next,
                                focusNode: _userNode,
                                onFieldSubmitted: (term) {
                                _fieldFocusChange(
                                    context, _userNode, _passwordNode);
                                },
                                decoration: InputDecoration(
                                    border: OutlineInputBorder(),
                                    labelText: 'Usuário'),
                            ),
                            ),
                            Container(
                            margin: EdgeInsets.all(20.0),
                            child: TextFormField(
                                textInputAction: TextInputAction.next,
                                focusNode: _passwordNode,
                                decoration: InputDecoration(
                                    border: OutlineInputBorder(), labelText: 'Senha'),
                            ),
                            ),
                            Container(
                            margin: EdgeInsets.all(20.0),
                            child: MaterialButton(
                                color: Colors.redAccent,
                                textColor: Colors.white,
                                onPressed: () => {},
                                child: Text('Registrar'),
                            ),
                            )

                        ],
                    ),
                    ),
                ),
                ),
            ),
            );
        }

        _fieldFocusChange(
            BuildContext context, FocusNode currentFocus, FocusNode nextFocus) {
            currentFocus.unfocus();
            FocusScope.of(context).requestFocus(nextFocus);
        }
        }

Second approach with Expand

    class _HomeState extends State<Home> {

    final _formKey = GlobalKey<FormState>();
    final _tokenNode = FocusNode();
    final _userNode = FocusNode();
    final _passwordNode = FocusNode();

    @override
    Widget build(BuildContext context) {
        return Scaffold(
        resizeToAvoidBottomInset: true,
        body: Container(
            child: Builder(
            builder: (context) => Form(
                key: _formKey,
                child: Column(
                crossAxisAlignment: CrossAxisAlignment.center,
                children: <Widget>[
                    Container(
                    child: Image.network("http://www.militaryzone.eu/www/ir/produkt-images/108561-image0--mm344x300.jpg",
                        fit: BoxFit.scaleDown,
                        width: 160,
                        alignment: Alignment.center),
                    margin: EdgeInsets.only(top: 100.0),
                    ),
                    Expanded(
                    child: ListView(shrinkWrap: true, children: <Widget>[
                        Container(
                        margin: EdgeInsets.all(20.0),
                        child: TextFormField(
                            textInputAction: TextInputAction.next,
                            focusNode: _tokenNode,
                            onFieldSubmitted: (term) {
                            _fieldFocusChange(context, _tokenNode, _userNode);
                            },
                            decoration: InputDecoration(
                            border: OutlineInputBorder(),
                            labelText: 'Chave ',
                            ),
                        ),
                        ),
                        Container(
                        margin: EdgeInsets.all(20.0),
                        child: TextFormField(
                            textInputAction: TextInputAction.next,
                            focusNode: _userNode,
                            onFieldSubmitted: (term) {
                            _fieldFocusChange(
                                context, _userNode, _passwordNode);
                            },
                            decoration: InputDecoration(
                                border: OutlineInputBorder(),
                                labelText: 'Usuário'),
                        ),
                        ),
                        Container(
                        margin: EdgeInsets.all(20.0),
                        child: TextFormField(
                            textInputAction: TextInputAction.next,
                            focusNode: _passwordNode,
                            decoration: InputDecoration(
                                border: OutlineInputBorder(), labelText: 'Senha'),
                        ),
                        ),
                        Container(
                        margin: EdgeInsets.all(20.0),
                        child: MaterialButton(
                            color: Colors.redAccent,
                            textColor: Colors.white,
                            onPressed: () => {},
                            child: Text('Registrar'),
                        ),
                        )
                    ]),
                    ),
                ],
                ),
            ),
            ),
        ),
        );
    }

    _fieldFocusChange(
        BuildContext context, FocusNode currentFocus, FocusNode nextFocus) {
        currentFocus.unfocus();
        FocusScope.of(context).requestFocus(nextFocus);
    }
    }

overflow: hidden - overflow, As much mud in the streets as if the waters had but newly retired from the If two keywords are specified, the first applies to overflow-x and the The box is not a scroll container, and does not start a new formatting context. Horizontal scrolling using Flexbox. If you create websites, chances are you have been asked to create a horizontal scrolling component. It is extremely easy to implement this using just a few lines of Flexbox. Let me show you how. Project Layout. We need to create a container that will contain all the images that we want to scroll. Here is the


You just have to wrap up your column with SingleChildScrollView Widget and you will get your soultion.

SingleChildScrollView(child: Column( children: <Widget>[]))

CSS Overflow, This text is really long and the height of its container is only 100 pixels. Therefore, a scrollbar is added to help the reader to scroll the content. Note: The overflow property only works for block elements with a specified height. Note: In OS X  By default, scroll snapping only kicks in when the user stops scrolling, meaning they can skip over several snap points before coming to a stop. You can change this by setting scroll-snap-stop: always on any child element. This forces the scroll container to stop on that element before the user can continue to scroll.


// If you need to scroll only the form part,

then simply wrap your ListView widget with Flexible widget.

  Scaffold(
  body: Container(
    child: Builder(
      builder: (context) => Form(
        key: _formKey,
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            Container(
              child: Image.network(
                  "https://buildflutter.com/wp-content/uploads/2018/04/buildflutter_255.png",
                  fit: BoxFit.scaleDown,
                  width: 160,
                  alignment: Alignment.center),
              margin: EdgeInsets.only(top: 100.0),
            ),
            Flexible(
              child: ListView(shrinkWrap: true, children: <Widget>[
                Container(
                  margin: EdgeInsets.all(20.0),
                  child: TextFormField(
                    textInputAction: TextInputAction.next,
                    focusNode: _tokenNode,
                    onFieldSubmitted: (term) {
                      _fieldFocusChange(context, _tokenNode, _userNode);
                    },
                    decoration: InputDecoration(
                      border: OutlineInputBorder(),
                      labelText: 'Chave ',
                    ),
                  ),
                ),
                Container(
                  margin: EdgeInsets.all(20.0),
                  child: TextFormField(
                    textInputAction: TextInputAction.next,
                    focusNode: _userNode,
                    onFieldSubmitted: (term) {
                      _fieldFocusChange(context, _userNode, _passwordNode);
                    },
                    decoration: InputDecoration(
                        border: OutlineInputBorder(), labelText: 'Usuário'),
                  ),
                ),
                Container(
                  margin: EdgeInsets.all(20.0),
                  child: TextFormField(
                    textInputAction: TextInputAction.next,
                    focusNode: _passwordNode,
                    decoration: InputDecoration(
                        border: OutlineInputBorder(), labelText: 'Senha'),
                  ),
                ),
                Container(
                  margin: EdgeInsets.all(20.0),
                  child: MaterialButton(
                    color: Colors.redAccent,
                    textColor: Colors.white,
                    onPressed: () => {},
                    child: Text('Registrar'),
                  ),
                )
              ]),
            ),
          ],
        ),
      ),
    ),
  ),
);

// If you need to scroll entire page

you need to wrap your Form widget inside the SingleChildScrollView widget.

SingleChildScrollView( scrollDirection: Axis.vertical, child: Form() // wrap your entire Form here. )

Pro Java ME Apps: Building Commercial Quality Java ME Apps, parent container might be off-screen because of its parent's scroll. For brevity, only vertical scroll is presented. value) needed to bring the specified widget into view in the current container, and then we apply said delta to the current scroll,  To enable y-scrolling simply set the scrollY parameter to be whatever you want the container wrapper's height to be (any CSS measurement is acceptable, or just a number which is treated as pixels). Note also that the scrollCollapse option is enabled in this example.


Practical CSS Scroll Snapping, CSS scroll snapping allows you to lock the viewport to certain elements or When the container element is scrolled, it will snap to the child elements you've defined. Since it only allows evenly-spaced snap points, you can't really build an  How To Create a Parallax Scrolling Effect. Use a container element and add a background image to the container with a specific height. Then use the background-attachment: fixed to create the actual parallax effect.


scroll-snap-stop, Scroll snapping refers to “locking” the position of the viewport to specific elements on the page as the window (or a scrollable container) is  The scrollIntoView() method scrolls the specified element into the visible area of the browser window.


Smooth Scroll, To enable SmoothScroll on internal links, just add the attribute data-smooth-scroll to the parent container like our Menu. Please note that each section needs a  You need to set a specific height on the "comments" div to make sure it knows exactly when to scroll. If there's not enough content to fill up that container beyond the specified height, the scrollbar might appear with overflow:scroll but it will be disabled.