navigateAndRemoveCurrent<V extends ViewModel> method

void navigateAndRemoveCurrent<V extends ViewModel>(
  1. {Object parameter}

Navigates to a new view modeland removed the calling viewmodel from the stack.

The parameter is a value that will be passed to the new viewmodel's init method. The Future will be resolved with the ViewModel that is navigated to is popped from the stack.


void navigateAndRemoveCurrent<V extends ViewModel>({Object parameter}) async {
  var _viewModel = createViewModel<V>(parameter);

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

  await Navigator.of(_viewContext)
      .popAndPushNamed(routeName, arguments: _viewModel);