draggablescrollablesheet flutter example

Example 1: flutter DraggableScrollableSheet

class HomePage extends StatelessWidget {
  
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('DraggableScrollableSheet'),
      ),
      body: SizedBox.expand(
        child: DraggableScrollableSheet(
          builder: (BuildContext context, ScrollController scrollController) {
            return Container(
              color: Colors.blue[100],
              child: ListView.builder(
                controller: scrollController,
                itemCount: 25,
                itemBuilder: (BuildContext context, int index) {
                  return ListTile(title: Text('Item $index'));
                },
              ),
            );
          },
        ),
      ),
    );
  }
}

Example 2: flutter draggable bottom sheet

DraggableScrollableSheet(  builder: (BuildContext context, myscrollController) {    return Container(      color: Colors.tealAccent[200],      child: ListView.builder(        controller: myscrollController,        itemCount: 25,        itemBuilder: (BuildContext context, int index) {          return ListTile(              title: Text(            'Dish $index',            style: TextStyle(color: Colors.black54),          ));        },      ),    );  },)

Tags:

Dart Example