Skip to content

ReorderableList does not pass itemExtentBuilder to underlying SliverReorderableList #155936

@Andre-lbc

Description

@Andre-lbc

Steps to reproduce

  1. Use ReorderableList widget similar to how you would use ListView.builder, utilizing the itemExtentBuilder parameter to set item extent.
  2. Observe that itemExtentBuilder is ignored and the list does not behave as expected when compared to ListView.builder or when using prototypeItem or itemExtent.

Expected results

The ReorderableList should pass the itemExtentBuilder parameter to the underlying SliverReorderableList, similar to how itemExtent and prototypeItem are already handled.

Actual results

Currently, itemExtentBuilder is not passed to the SliverReorderableList in ReorderableListState's build method, which causes it to be ignored.

Code sample

Code sample
class MyScrollList extends StatelessWidget {
  const MyScrollList({super.key});

  @override
  Widget build(BuildContext context) {
    return ReorderableList(
      // This works
      // itemExtent: 50,

      // This works
      // prototypeItem: const SizedBox(height: 50),

      // This does not work
      itemExtentBuilder: (index, dimensions) {
        return 50;
      },
      onReorder: (oldIndex, newIndex) {
        // ...
      },
      itemCount: 5,
      itemBuilder: (context, index) {
        return Container(
          key: ValueKey('item$index'),
          child: Text('Item $index'),
        );
      },
    );
  }
}
Proposed fix sample
class ReorderableListState extends State<ReorderableList> {

// ...

@override
  Widget build(BuildContext context) {
    return CustomScrollView(
      scrollDirection: widget.scrollDirection,
      reverse: widget.reverse,
      controller: widget.controller,
      primary: widget.primary,
      physics: widget.physics,
      shrinkWrap: widget.shrinkWrap,
      anchor: widget.anchor,
      cacheExtent: widget.cacheExtent,
      dragStartBehavior: widget.dragStartBehavior,
      keyboardDismissBehavior: widget.keyboardDismissBehavior,
      restorationId: widget.restorationId,
      clipBehavior: widget.clipBehavior,
      slivers: <Widget>[
        SliverPadding(
          padding: widget.padding ?? EdgeInsets.zero,
          sliver: SliverReorderableList(
            key: _sliverReorderableListKey,
            itemExtent: widget.itemExtent,
            prototypeItem: widget.prototypeItem,
            // Add this line:
            itemExtentBuilder: widget.itemExtentBuilder,
            itemBuilder: widget.itemBuilder,
            itemCount: widget.itemCount,
            onReorder: widget.onReorder,
            onReorderStart: widget.onReorderStart,
            onReorderEnd: widget.onReorderEnd,
            proxyDecorator: widget.proxyDecorator,
            autoScrollerVelocityScalar: widget.autoScrollerVelocityScalar,
          ),
        ),
      ],
    );
  }

// ...

}

Screenshots or Video

No response

Logs

No response

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.24.3, on macOS 14.6.1 23G93 darwin-arm64, locale en-BR)
    • Flutter version 3.24.3 on channel stable at /Users/andrelbc/Dev/Flutter/Sdk/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2663184aa7 (3 weeks ago), 2024-09-11 16:27:48 -0500
    • Engine revision 36335019a8
    • Dart version 3.5.3
    • DevTools version 2.37.3

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0-rc4)
    • Android SDK at /Users/andrelbc/Library/Android/sdk
    • Platform android-35, build-tools 35.0.0-rc4
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11609105)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.15.2

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

[✓] Android Studio (version 2024.1)
    • 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 17.0.10+0-17.0.10b1087.21-11609105)

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

[✓] VS Code (version 1.89.0-insider)
    • VS Code at /Applications/Visual Studio Code - Insiders.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (4 available)
    • iPad mini (6th generation) (mobile) • 17517532-9DFB-46FA-AA12-4DA1BC650870 • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-17-5 (simulator)
    • macOS (desktop)                     • macos                                • darwin-arm64   • macOS 14.6.1 23G93 darwin-arm64
    • Mac Designed for iPad (desktop)     • mac-designed-for-ipad                • darwin         • macOS 14.6.1 23G93 darwin-arm64
    • Chrome (web)                        • chrome                               • web-javascript • Google Chrome 129.0.6668.70

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    f: scrollingViewports, list views, slivers, etc.found in release: 3.24Found to occur in 3.24found in release: 3.26Found to occur in 3.26frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions