Search code examples
flutter

Flutter SingleChildScrollView not scrolling


My singleChildScollView won't scroll vertically. I've checked similar questions regarding this problem but none of them sem to work for me. The page fills up with the items, and the homepage button is placed at the bottom...

enter image description here

...so it looks correct, it just doesn't let me scroll.

Scaffold(
    body: SingleChildScrollView(
               child: ListView.builder(
                           scrollDirection: Axis.vertical,
                           shrinkWrap: true,
                           itemBuilder: (ctx, index) {
                                  ...list of items here...
                           }
                      ),
          ),
)

Edit

Note in the example code above I have simplified the original widget tree and removed the homepage button.


Solution

  • @james please check it

    Scaffold(
          body: Stack(
          children: [
            SingleChildScrollView(
              child: ListView.builder(
                  scrollDirection: Axis.vertical,
                  shrinkWrap: true,
                  physics: ScrollPhysics(),
                  itemCount: 30,
                  itemBuilder: (ctx, index) {
                    return Padding(
                      padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
                      child: Text("index $index"),
                    );
                  }
              ),
            ),
            Align(
              alignment: Alignment.bottomCenter,
              child: ElevatedButton(
                onPressed: () {Navigator.pop(context);},
                child: Text('Homepage'),
              ),
            ),
    
          ],
        ),
        )