How to achieve a behavior when you can drag a bottom sheet but can't dismiss it, e.g., in Uber
Asked
Active
Viewed 495 times
0

Andrew Piterov
- 340
- 3
- 12
-
Maybe `DraggableScrollableSheet` can be helpful – jraufeisen Aug 23 '22 at 16:27
-
Please check this. https://stackoverflow.com/a/62936607/16616583. It might help you. – Faizan Darwesh Aug 23 '22 at 18:55
-
Packages like snapping_sheet can be used – S Sharanya Bharghavi May 01 '23 at 08:52
1 Answers
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,
)

S Sharanya Bharghavi
- 109
- 1
- 11