Search code examples
flutterlistviewsinglechildscrollview

What is wrong with my scrollable listview?


New to flutter, trying to make a scrollable page that contain a long listview. I tried a few different things that I've read on different SO pages, so my code may look bloated. I am not sure why even though the page showed up fine, and the last ListTile's image showed up, I can't scroll down the screen to see the rest of that image.

class About extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        backgroundColor: Colors.amberAccent,
        appBar: AppBar(
          title: Text('About this App'),
          backgroundColor: Colors.lightGreen[400],
          centerTitle: true,
        ),
        body: SingleChildScrollView(
            scrollDirection: Axis.vertical,
            child: Column(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: <Widget>[
                  Text(
                      'The following people helped made my first app possible:',
                      textAlign: TextAlign.center,
                      style: TextStyle(
                          fontSize: 20,
                          color: Colors.black,
                          fontWeight: FontWeight.bold)),
                  ListView(
                    shrinkWrap: true,
                    padding: EdgeInsets.all(15.0),
                    children: <Widget>[
                      ListTile(
                        leading: Text('Me'),
                        title: Text(
                            'a little about myself'),
                      ),
                      ListTile(
                        leading: Text('Coworker'),
                        title: Text(
                            'Contribution made by coworker'),
                      ),
                      ListTile(
                        leading: Text('Friend'),
                        title: Text(
                            'Message about friend'),
                      ),
                      ListTile(
                        title: SizedBox(
                            height: 500.0,
                            width: 500.0,
                            child: Image.asset('images/friend.jpeg')),
                      ),
                    ],
                  ),
                ])));
  }
}```

Solution

  • In your Listview use physics: ScrollPhysics(), for a more detailed answer see the link below

    How to implement Nested ListView in Flutter?