kitta
kitta

Reputation: 2069

How to make SingleChildScrollView scrollable even content hight is lower than the scroll view height?

Unlike native iOS, Scrollable could still scroll even there is only a little height of the content inside the scroll view. So the question is:

How to make SingleChildScrollView scrollable even content hight is lower than the scroll view height?

FYI, Even I expanded my content to fit the parent container. following this link, The SingleChildScrollView still couldn't scroll.

Upvotes: 2

Views: 876

Answers (2)

Danilo
Danilo

Reputation: 391

child: SingleChildScrollView(
  physics: const AlwaysScrollableScrollPhysics(), // <-- just add this
  child: (...),
)

Upvotes: 2

wcyankees424
wcyankees424

Reputation: 2654

Here this is definitely a hack but it works it doesn't seem like this should be this hard to figure out. If this is unacceptable to you let me know I'll see what else I can figure out that is more legit.

  Container(
          height: 400,
          child: ListView(
            children: <Widget>[
              Container(
                padding: const EdgeInsets.symmetric(vertical: 500),
                child: Column(
                  children: <Widget>[
                    ...numbers.map(
                      (number) => Text(
                        number.toString(),
                        textAlign: TextAlign.center,
                        style: TextStyle(fontSize: 20),
                      ),
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),

I did not try this with SingleChildScrollView

Upvotes: 1

Related Questions