rapideTicketNavigatorContextForOverlay function
Context suited for Navigator.push / RapideTicket.showFeedback: first
Navigator.maybeOf, else first NavigatorState in scope's subtree.
Needed when this widget sits above Navigator (e.g. return from MaterialApp.builder): the scope BuildContext then has no Navigator ancestor.
Implementation
BuildContext? rapideTicketNavigatorContextForOverlay(BuildContext scope) {
final fromAncestor = Navigator.maybeOf(scope);
if (fromAncestor != null && fromAncestor.mounted) {
return fromAncestor.context;
}
final Element? el = scope as Element?;
if (el == null) return null;
final found = _findNavigatorStateInSubtree(el);
if (found != null && found.mounted) {
return found.context;
}
return null;
}