【问题标题】:How do I make the top three widget scroll with the rest of the page?如何使前三个小部件与页面的其余部分一起滚动?
【发布时间】:2022-01-13 20:45:38
【问题描述】:

我有以下代码。我需要让 StorySwipeList、_SearchBar 和 SizedBoxes 与页面的其余部分一起滚动。 Listview Builder 滚动没有问题。但是顶部的 StorySwipeList、Sizedboxes 和 _searchBar 不想随着它们滚动。

我在滚动视图和列表视图中添加了一个已删除的 Neverscroll 物理,我已将第一个列表视图替换为一列并反转,添加了始终可滚动的物理等。似乎没有什么可以使那部分小部件移动。

有人知道怎么做吗?

return SafeArea(
      child: Scaffold(
        extendBody: false,
        extendBodyBehindAppBar: false,
        backgroundColor: HexColor('#0A0928'),
        body: SingleChildScrollView(
          physics: AlwaysScrollableScrollPhysics(),
          child: ListView(
            shrinkWrap: true,
            children: [
              StorySwipeList(
                  latestProTracks: pageManager.latestProTracksNotifier.value),
              SizedBox(
                height: 10,
              ),
              _searchBar(),
              SizedBox(
                height: 10,
              ),
              ValueListenableBuilder<List<MediaItem>>(
                valueListenable: pageManager.filteredMainPlaylistNotifier,
                builder: (context, playlist, _) {
                  TestLog.log('HOME PAGE: playlist size ${playlist.length}');
                  return SizedBox(
                    height: MediaQuery.of(context).size.height * 0.7,
                    child: ListView.builder(
                      physics: AlwaysScrollableScrollPhysics(),
                      shrinkWrap: true,
                      itemCount: playlist.length,
                      itemBuilder: (context, index) {
                        return PlaylistTrack(
                          index: index,
                          playlist: playlist,
                          track: playlist[index],
                          currentUserId: currentUserId,
                          playlistName: 'Main',
                        );

【问题讨论】:

    标签: flutter listview scroll singlechildscrollview


    【解决方案1】:

    尝试在主 ListView 中设置 primary: true,。你可以在其他的里面设置成false

    【讨论】:

    • 您好,感谢您的回复。不幸的是,这不起作用。
    【解决方案2】:

    移除 Sized Box 的高度限制似乎可以解决问题。

    height: MediaQuery.of(context).size.height * 0.7,
    

    【讨论】:

      猜你喜欢
      • 2013-12-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-04
      • 1970-01-01
      • 2022-01-22
      • 2014-09-19
      • 2021-09-23
      相关资源
      最近更新 更多