title: Make showCupertinoModalPopup to return a value
body: <p>Flutter reference documentation shows an example of using CupertinoPicker class wrapped by CupertinoModalPopupRoute popup Dialog:
  <a href="https://api.flutter.dev/flutter/cupertino/CupertinoPicker-class.html" rel="nofollow noreferrer">https://api.flutter.dev/flutter/cupertino/CupertinoPicker-class.html</a> (dartpad snippet available)</p>
  <p>The Dialog with a CupertinoPicker pops up, once a button is clicked. Button's onPressed calls:</p>
  <pre><code>  void _showDialog(Widget child) {
      showCupertinoModalPopup&lt;void&gt;(
          context: context,
          builder: (BuildContext context) =&gt; Container(
                // some UI setting omitted 
                child: SafeArea(
                  top: false,
                  child: child,
                ),
              ));
    }
  </code></pre>
  <p>where child is:</p>
  <pre><code>  CupertinoPicker(
      // some UI setting omitted 
      onSelectedItemChanged: (int selectedItem) {
        setState(() {
          _selectedFruit = selectedItem;
        });
      },
      children:
          List&lt;Widget&gt;.generate(_fruitNames.length, (int index) {
        return Center(
          child: Text(
            _fruitNames[index],
          ),
        );
      }),
    ),
      
  </code></pre>
  <p>Method showCupertinoModalPopup used to push a Dialog with a Picker just above the main page.</p>
  <ol>
  <li>Method's annotation mentions that &quot;Content below the widget is dimmed with a [ModalBarrier]&quot;, and exactly ModalBarrier's handleDismiss method is called once user taps outside the Dialog's area, this leads to Navigator.pop being called, which pops the Dialog returning default void value (I cannot find a way to pass custom callback to the ModalBarrier)</li>
  <li>Again from the showCupertinoModalPopup's annotation:
  &quot;Returns a <code>Future</code> that resolves to the value that was passed to
  [Navigator.pop] when the popup was closed.&quot;</li>
  </ol>
  <p>So the question is, what is the right way (if any) to override Navigator.pop to make showCupertinoModalPopup return a value? I don't want to use Picker's onSelectedItemChanged as it constantly changes the state while user choses right value.</p>
  <p>Instead I would use it like:</p>
  <pre><code>Future&lt;void&gt; _showDialog(Widget child) async {
      int? value = await showCupertinoModalPopup&lt;int&gt;(
          context: context,
          builder: (BuildContext context) =&gt; Container(
               //omitted
                child: SafeArea(
                  top: false,
                  child: child,
                ),
              ));
  
      setState(() {
        Provider.of&lt;FruitsController&gt;(context, listen: false).currentFruit = value;
      });
    }
  </code></pre>
  <p>I would appreciate your help.</p>