I am following this udemy course(<https://www.udemy.com/learn-flutter-dart-to-build-ios-android-apps>) on flutter, and using scoped\_model for state management.
I want to edit a product from list of products. For that I set the product id as a flag - selectedProductId in scoped model. When submitting, I want to navigate away and set this selectedProductId to null.

```
//method to edit product    
editProduct(productId, newValues);
Navigator.pushReplacementNamed(context, '/productsPage').then((_){
   debugger();
setSelectedProductId(null);
}).catchError((err){print(err);});

```

The debugger is never hit. and there is no error either.

I tried using async await and still no use.

```
editProduct(editableProductId, _formData);
await Navigator.pushReplacementNamed(context, '/productsPage').catchError((err){print(err);});
debugger();
setSelectedProductId(null);

```

the page is navigated to the given route, but the line after, is never executed. I even tried using `pushNamed` instead of `pushReplacementNamed`.

I know that `pushReplacementNamed` returns a future, so .then() must be called, but doesn't seem to happen, am I missing something? Are there any other factors or situations I should know?