expandable_bottom_sheet
expandable_bottom_sheet copied to clipboard
scroll close not work with list
if the drag list is reach to top, the bottom sheet should be scroll to close. It work with other widget, just not with list
import 'package:expandable_bottom_sheet/expandable_bottom_sheet.dart';
import 'package:flutter/material.dart';
class SheetTest extends StatefulWidget {
SheetTest({Key key}) : super(key: key);
@override
_SheetTestState createState() => _SheetTestState();
}
class _SheetTestState extends State<SheetTest> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: ExpandableBottomSheet(
background: Container(
color: Colors.red,
child: Center(
child: Text('Background'),
),
),
persistentHeader: Container(
height: 40,
color: Colors.blue,
child: Center(
child: Text('Header'),
),
),
expandableContent: Container(
height: 500,
color: Colors.green,
child: ListView.builder(
itemCount: 30,
itemBuilder: (BuildContext context, int index) {
return ListTile(title: Text('$index'));
},
),
),
),
);
}
}
@shinewanna What exactly do you mean? Can you maybe add a short screen recording so I can understand the problem better?
When use a scrollable widget like a ListView inside the expandable_bottom_sheet widget drag gesture not working in these area. I use a workaround with NotificationListening to solve it
NotificationListener<ScrollNotification>(
onNotification: scrollHandler,
child: ListView.builder(
physics: const BouncingScrollPhysics(),
itemCount: 200,
itemBuilder: (context, index) {
return Text('Test');
}
),
),
bool scrollHandler(ScrollNotification notification) {
if (notification.depth == 0) {
if (notification is UserScrollNotification) {
if (notification.metrics.extentBefore == 0 &&
notification.direction == ScrollDirection.forward
) {
key.currentState!.contract();
}
}
}
return false;
}