首页 > 解决方案 > 如何仅滚动具有另一个滚动视图的滚动视图内的子项

问题描述

我有 ListView 并且在 singleChildScrollView 中包含 pdf 文档的子项只想滚动 singleChildScrollView 而不是扩展后的 listView

下面是我的代码

Column(
  children: <Widget>[
    Container(
      margin: EdgeInsets.only(right: 15, top: 10),
      width: size.width,
      child: Text("Title should be Pinned",
        textAlign: TextAlign.end,
      ),
    ),
    SizedBox(
      height: 20,
    ),
    Theme(
      data: ThemeData(
        accentColor: Colors.black,
        primaryColor: Colors.white24,
      ),
      child: Expanded(
        child: ListView.builder(
          itemCount: data.length,
          itemBuilder: (context, i) => ExpansionTile(
            title: Center(
              child: Text(
                "After Expansion this should be pinned and only children should be scrollable"
              ),
            ),
            children: [
              Container(
                child: SingleChildScrollView( //should be scrollable on expanded and not the title of ExpansionTile
                  child: SfPdfViewer.network(
                    '$url',
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    )
  ],
),

标签: flutterflutter-layout

解决方案


在容器中扭曲你的小部件并给它一个高度使用滚动小部件内的以下参数

收缩包装:假,主要:真


推荐阅读