popWithResult method

Future<Null> popWithResult({
  1. dynamic result,
  2. bool shouldCloseOnly = false,
})

Dismisses this panel and then triggers a Notification with given result.

Returned future is completed when the panel is dismissed.

The result can be anything except null.

Useful in cases like, dismiss the panel and then return some value back to the parent when user taps some item inside panel.

If shouldCloseOnly is true, then panel will close instead of being dismissed.

This can be thought of as example of Navigator.pop with result.

Implementation

Future<Null> popWithResult(
    {dynamic result, bool shouldCloseOnly = false}) async {
  panel!._shouldNotifyOnClose = false;

  if (shouldCloseOnly)
    return close().then((_) {
      sendResult(result: result);
    });

  return dismiss().then((_) {
    sendResult(result: result);
  });
}