Persistent draggable bottom sheet in Flutter

7,262

Solution 1

Perhaps DraggableScrollableSheet could work?

I haven't yet tried it out myself, but maybe you could fiddle with a listview to make it work.

I'm guessing something like having it's child be a listview, and then limit both the max child size and the maximum scroll extent

Solution 2

If you do not care that the bottom sheet must snap to different positions you can use the widget from the following package (snapping_sheet) I made.

Or, if you do not want to use it as a 3rd part library, you can copy the code and use it as your own widget from repository here: Github - Snapping sheet

Solution 3

Use DraggableScrollableSheet. Here's an example:

Stack(
children: [
  Container(), //the page under the DraggableScrollableSheet goes here
  Container(
    height: MediaQuery.of(context).size.height,
    child: DraggableScrollableSheet(
      builder: (BuildContext context, myscrollController) {
        return Container(
          color: Colors.blue,
          child: ListView.builder(
            controller: myscrollController,
            itemCount: 40,
            itemBuilder:(BuildContext context, int index) {
              return ListTile(title: Text('Item $index',
                style: TextStyle(color: Colors.black),
              ));
            },
          ),
        );
      },
    ),
  ),
],),
Share:
7,262
superuser
Author by

superuser

Updated on December 12, 2022

Comments

  • superuser
    superuser over 1 year

    I'm using Rubber library at the moment, do you know an approach without using 3rd parts libraries? The Bottom Sheet must be persistent (not dismissable, not triggered by any button instead, always displayed) and draggable (It must be expanded and collapsed by dragging gestures)

  • Obumuneme Nwabude
    Obumuneme Nwabude about 2 years
    Worked very well