Repository navigation
Multiple SliverChildBuilderDelegates always build the first child #95028
Copy link
Copy link
Closed
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: layoutSystemChrome and Framework's Layout IssuesSystemChrome and Framework's Layout Issuesa: qualityA truly polished experienceA truly polished experienced: api docsIssues with https://api.flutter.dev/Issues with https://api.flutter.dev/d: examplesSample code and demosSample code and demosf: scrollingViewports, list views, slivers, etc.Viewports, list views, slivers, etc.frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.
Description
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: layoutSystemChrome and Framework's Layout IssuesSystemChrome and Framework's Layout Issuesa: qualityA truly polished experienceA truly polished experienced: api docsIssues with https://api.flutter.dev/Issues with https://api.flutter.dev/d: examplesSample code and demosSample code and demosf: scrollingViewports, list views, slivers, etc.Viewports, list views, slivers, etc.frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.
Activity
Piinks commentedon Jan 31, 2022
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.
davidmartos96 commentedon Feb 3, 2022
@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?
Piinks commentedon Feb 15, 2022
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. :)
github-actions commentedon Mar 1, 2022
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 -vand a minimal reproduction of the issue.