【问题标题】:Scrolling with a listview in Flutter在 Flutter 中使用列表视图滚动
【发布时间】:2020-11-05 08:00:16
【问题描述】:

我在使用 Flutter 时遇到问题,其中我创建的屏幕只有在用户触摸由卡片组成的列表视图周围的填充时才会滚动,而不是在实际列表与其自身交互时滚动。

Widget 树如下所示:

child: Scaffold(
        body: SingleChildScrollView(
          child: Center(
            child: SizedBox(
              width: 500.0,
              child: Padding(
                padding: const EdgeInsets.all(8.0),
                child: Column(
                  children: [
                    Text(
                      'List',                       
                     ),
                    Container(
                      child: ListView.builder(
                        shrinkWrap: true,
                        itemCount: list.length,
                        itemBuilder: (context, index) {
                          return Card(                            
                              child: ListTile(

无论用户触摸屏幕的哪个位置,我如何才能使屏幕可滚动?

【问题讨论】:

    标签: flutter dart vertical-scrolling


    【解决方案1】:

    在列表视图中添加NeverScrollableScrollPhysics

    ListView.builder(
                    shrinkWrap: true,
                    physics: NeverScrollableScrollPhysics(),
    

    【讨论】:

    • 谢谢,这似乎完全解决了我想要实现的目标!
    猜你喜欢
    • 2018-12-23
    • 2020-07-16
    • 2020-05-17
    • 2022-12-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-03
    • 1970-01-01
    相关资源
    最近更新 更多