routemaster icon indicating copy to clipboard operation
routemaster copied to clipboard

Add `canPop()` to `RoutemasterDelegate`

Open RastislavMirek opened this issue 3 years ago • 2 comments

Using Navigator.of(context).canPop() does not give valid results when used with RoutemasterDelegate , i.e. it returns true when in fact the route cannot be popped. This happens when you have tab bar with nested stack navigators. At the tabs it returns true but there is nothing to pop.

This means that this exception is really hard to avoid (while it should be trivial, just checking canPop() value):

CupertinoNavigationBarBackButton should only be used in routes that can be popped
'package:flutter/src/cupertino/nav_bar.dart':
Failed assertion: line 1312 pos 9: 'currentRoute?.canPop == true'

Proposed solution: Add canPop() method to RoutemasterDelegate that will always return the correct value.

RastislavMirek avatar Jul 03 '21 13:07 RastislavMirek

Are you able to provide a repro of where this happens please? I'd like to understand why Navigator.of(context).canPop() is returning the wrong result; it shouldn't.

tomgilder avatar Jul 18 '21 12:07 tomgilder

This is happening in complex project that is not open sourced and I do not have capacity to create repro repository at the moment. However, I keep it on my task list and will get to it.

RastislavMirek avatar Jul 23 '21 22:07 RastislavMirek