Flutter onClosing callback for showModalBottomSheet

前端 未结 8 1188
梦如初夏
梦如初夏 2021-02-04 00:50

I have a showModalBottomSheet like the below, which I understand to inherit from BottomSheet (right?)

      showModalBottomSheet

        
8条回答
  •  旧巷少年郎
    2021-02-04 01:50

    Perhaps it's not the best solution, but showModalBottomSheet return a "Future" so you can used it.

    For example:

    void _showModal() {
        Future future = showModalBottomSheet(
          context: context,
          builder: (BuildContext context) {
            return Container(height: 260.0, child: Text('I am text'));
          },
        );
        future.then((void value) => _closeModal(value));
    }
    void _closeModal(void value) {
        print('modal closed');
    }
    

提交回复
热议问题