navigateForResult<R extends Object, V extends ViewModel> method

Future<R> navigateForResult<R extends Object, V extends ViewModel>(
  1. {Object parameter}
)
override

Navigates to a new viewmodel of the type specified by the generic.

The parameter is a value that will be passed to the new viewmodel's init method. It is expexted that the ViewModel being navigated to will return an instance of type R when it is popped off the stack.

Implementation

Future<R> navigateForResult<R extends Object, V extends ViewModel>(
    {Object parameter}) async {
  var _viewModel = createViewModel<V>(parameter);

  var routeName = Core._viewLocator.getViewFromViewModelType<V>();

  var returnValue = await Navigator.of(_viewContext)
      .pushNamed<R>(routeName, arguments: _viewModel);

  _viewModel.dispose();

  return returnValue;
}