Flutter DraggableScrollableSheet doesn't show up by pressing button

前端 未结 3 873
日久生厌
日久生厌 2020-12-16 04:03

I want to use DraggableScrollableSheet widget on my application, when I use that like with below code, that can show without problem:

class Home         


        
3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-16 05:00


    If you want to use DraggableScrollableSheet inside showModalBottomSheet, you can simply call this function.

    void _showSheet() {
      showModalBottomSheet(
        context: context,
        isScrollControlled: true, // set this to true
        builder: (_) {
          return DraggableScrollableSheet(
            expand: false,
            builder: (_, controller) {
              return Container(
                color: Colors.blue[500],
                child: ListView.builder(
                  controller: controller, // set this too
                  itemBuilder: (_, i) => ListTile(title: Text('Item $i')),
                ),
              );
            },
          );
        },
      );
    }
    

提交回复
热议问题