of static method

The presentation in force at context: the one a RoutePresentationScope publishes (a sheet page publishes sheet), else the route's own position — pushed when the route implies a dismissal (a route stands below it in its navigator), root otherwise, and root outside any route.

Asked of the route, never of the navigator's canPop: a sheet raised over a root on the same navigator makes canPop true for the root too, which would give the root a back affordance under the sheet.

Implementation

static RoutePresentation of(BuildContext context) {
  final published = RoutePresentationScope.maybeOf(context);
  if (published != null) return published;
  final route = ModalRoute.of(context);
  return (route?.impliesAppBarDismissal ?? false) ? pushed : root;
}