0

showModalBottomsheet adds listview as a child Widget. When listview slides to the top, how to respond to the bottom sheet drop-down gesture by continuing to pull down

showModalBottomSheet(
        context: context,
        isScrollControlled: true,
        constraints: BoxConstraints(
          maxHeight: MediaQuery.of(context).size.height * 0.85),
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.only(
              topRight: Radius.circular(20),
              topLeft: Radius.circular(20)),
        ),
        builder: (context) {
          return ListView.builder(
                      controller: scrollController,
                      itemBuilder: (context, index) => ListTile(
                            title: Text(index.toString()),
                            onTap: () => Navigator.pop(context),
                          ));
        });
Md. Yeasin Sheikh
  • 54,221
  • 7
  • 29
  • 56

1 Answers1

0

You can use DraggableScrollableSheet

showModalBottomSheet(
  context: context,
  isScrollControlled: true,
  constraints: BoxConstraints(
      maxHeight: MediaQuery.of(context).size.height * 0.85),
  shape: const RoundedRectangleBorder(
    borderRadius: BorderRadius.only(
        topRight: Radius.circular(20), topLeft: Radius.circular(20)),
  ),
  builder: (context) {
    return DraggableScrollableSheet(
      builder: (context, scrollController) {
        return ListView.builder(
          itemCount: 32,
          controller: scrollController,
          itemBuilder: (context, index) => ListTile(
            title: Text(index.toString()),
            onTap: () => Navigator.pop(context),
          ),
        );
      },
    );
  },
);

Find more about DraggableScrollableSheet decoration

Md. Yeasin Sheikh
  • 54,221
  • 7
  • 29
  • 56