我的可滚动列表视图有什么问题?

科学先生

flutter 新手,尝试制作一个包含长列表视图的可滚动页面。我尝试了一些在不同 SO 页面上阅读过的不同内容,因此我的代码可能看起来很臃肿。我不知道为什么即使页面显示正常,并且显示了最后一个 ListTile 的图像,我也无法向下滚动屏幕以查看该图像的其余部分。

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')),
                      ),
                    ],
                  ),
                ])));
  }
}```
瓦利汗

在您的 Listview 中使用physics: ScrollPhysics(),更详细的答案,请参阅下面的链接

如何在 Flutter 中实现嵌套 ListView?

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章