Skip to content

Multiple SliverChildBuilderDelegates always build the first child #95028

Closed

Description

@Piinks

From discussion in #26072, this Dartpad shows that the first item in every SliverList (using a lazy SliverChildBuilderDelegate) is built regardless of whether it is visible in the viewport.
This is significantly better than using shrinkwrap 💀 but it is still not as expected.

flutter doctor -v

[✓] Flutter (Channel master, 2.6.0-12.0.pre.993, on macOS 12.0.1 21A559 darwin-x64,
    locale en-US)
    • Flutter version 2.6.0-12.0.pre.993 at /Users/katelovett/github/flutter
    • Upstream repository [email protected]:flutter/flutter.git
    • Framework revision 2ebd07aec4 (21 hours ago), 2021-12-09 13:47:11 -0800
    • Engine revision 89e17d94cb
    • Dart version 2.16.0 (build 2.16.0-85.0.dev)
    • DevTools version 2.9.1

[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0-rc1)
    • Android SDK at /Users/katelovett/Library/Android/sdk
    • Platform android-32, build-tools 32.0.0-rc1
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS (Xcode 13.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    ! CocoaPods 1.8.4 out of date (1.10.0 is recommended).
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin code
        that responds to your plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To upgrade see
      https://guides.cocoapods.org/using/getting-started.html#installation for
      instructions.

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)

[✓] IntelliJ IDEA Ultimate Edition (version 2021.2.3)
    • IntelliJ at /Applications/IntelliJ UE (stable).app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.63.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.29.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 12.0.1 21A559 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 96.0.4664.93

! Doctor found issues in 1 category.

Activity

  1. added
    a: layoutSystemChrome and Framework's Layout Issues
    a: qualityA truly polished experience
    f: scrollingViewports, list views, slivers, etc.
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Dec 10, 2021
  2. self-assigned this
    on Dec 10, 2021
  3. Piinks commented on Jan 31, 2022

    @Piinks
    ContributorAuthor

    After doing some digging, I have found that this is intentional behavior. Currently, we must layout at least one child in order to estimate the maximum scroll offset. We should update the documentation to better explain this, and maybe also include some example code showing how one could override the way maxScrollExtent is estimated for SliverLists and SliverGrids.

  4. added
    d: api docsIssues with https://api.flutter.dev/
    P2Important issues not at the top of the work list
    on Jan 31, 2022
  5. davidmartos96 commented on Feb 3, 2022

    @davidmartos96
    Contributor

    @Piinks Happy to see this moving forward.
    Knowing the problem now, is there any example on how we can achieve the "deadly" Dartpad above in a performant way?

  6. Piinks commented on Feb 15, 2022

    @Piinks
    ContributorAuthor

    Currently, the above dartpad is the most performant for that composition, it is certainly a lot better than shrinkwrap. There are a lot of ways to compose widgets though, so there could be another way that I haven't thought of.
    I filed #97676 to look into different methods for estimating the max scroll offset without requiring at least one child be built. I would follow up there if you are interested. :)

  7. github-actions commented on Mar 1, 2022

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  8. locked as resolved and limited conversation to collaborators on Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: layoutSystemChrome and Framework's Layout Issuesa: qualityA truly polished experienced: api docsIssues with https://api.flutter.dev/d: examplesSample code and demosf: scrollingViewports, list views, slivers, etc.frameworkflutter/packages/flutter repository. See also f: labels.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions