0

How to achieve a behavior when you can drag a bottom sheet but can't dismiss it, e.g., in Uber

enter image description here

Andrew Piterov
  • 340
  • 3
  • 12

1 Answers1

2

You can use DraggableScrollableSheet and set minChildSize to whatever height you want persisting.

 DraggableScrollableSheet(
  initialChildSize: _currentHeight,
  minChildSize: 0.2,
  maxChildSize: 1.0,
  builder: (BuildContext context, ScrollController scrollController) {
    return Container(
      decoration: const BoxDecoration(
        color: Colors.red,
        borderRadius: BorderRadius.only(
          topLeft: Radius.circular(30),
          topRight: Radius.circular(30),
        ),
      ),
      child: ListView.builder(
        controller: scrollController,
        itemCount: 5,
        itemBuilder: (BuildContext context, int index) {
          return ListTile(
            title: Text('Item $index'),
          );
        },
      ),
    );
  },
  expand: false,
)