Flutter onClosing callback for showModalBottomSheet

前端 未结 8 1164
梦如初夏
梦如初夏 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:43

    I personally think the accepted answer is not as sleek as it can be. A wiser idea is to do it native Dart way without any extra complexity:

    () async {
          final result = await showModalBottomSheet(context: context, builder: (_) =>
    
          );
    }
    

    It also works with Navigator.of(context).pushNamed(). result variable value in my case is defined by the value you pass back on Navigator.of(context).pop({value}). You can return any kind of object and then make a simple if statement to make sure data is the one you want:

    if(result != null && result == true) { ... }
    

提交回复
热议问题