modalBottomSheet + ListView, how to sync scroll?

Viewed 20

I have a modalBottomSheet with a scrolling list view inside of it.

I want for the scroll control to be transferred to the bottom sheet when the listView reaches the top, so that it can be dragged to dismiss.

Now, the listView gets to the top and even if I keep dragging the bottom sheet will not be dismissed on drag.

Thank you!

1 Answers

Try this way

showModalBottomSheet(
  context: context,
  isScrollControlled: true,
  builder: (context) {
    return DraggableScrollableSheet(
      maxChildSize: 1,
      initialChildSize: .5,
      expand: false,
      builder: (context, scrollController) {
        return ListView.builder(
          itemCount: 44,
          controller: scrollController,
          itemBuilder: (context, index) => ListTile(
            title: Text("item $index"),
          ),
        );
      },
    );
  },
);
Related