how to set showModalBottomSheet to full height

后端 未结 5 1892
星月不相逢
星月不相逢 2020-12-14 02:01

i use showRoundedModalBottomSheet, how to adjust this modal height till below the appbar?

5条回答
  •  旧巷少年郎
    2020-12-14 02:15

    If you call showModalBottomSheet() with isScrollControlled: true, then the dialog will be allowed to occupy the whole height.

    To adjust the height to the content, you can proceed as usually, for example, using Container and Wrap widgets.

    Example:

    final items = [
      ListTile(
        leading: Icon(Icons.photo_camera),
        title: Text('Camera'),
        onTap: () {},
      ),
      ListTile(
        leading: Icon(Icons.photo_library),
        title: Text('Select'),
        onTap: () {},
      ),
      ListTile(
        leading: Icon(Icons.delete),
        title: Text('Delete'),
        onTap: () {},
      ),
      Divider(),
      if (true)
        ListTile(
          title: Text('Cancel'),
          onTap: () {},
        ),
    ];
    
    showModalBottomSheet(
      context: context,
      builder: (BuildContext _) {
        return Container(
          child: Wrap(
            children: items,
          ),
        );
      },
      isScrollControlled: true,
    );
    

提交回复
热议问题