onNavigate method
Record a transition to to.
Implementation
Future<bool> onNavigate(String to, {String? from}) async {
if (!ActionGates.instance.localCacheEnabled) return false;
if (!_initialized) {
if (_pendingNavigations.length < _kMaxPendingNavigations) {
_pendingNavigations.add(_PendingNavigation(to, from));
}
return false;
}
final t = to.trim();
if (t.isEmpty || t == kUnknownFlow || t == kUnknownScreen) return false;
final f = (from ?? _lastNavigatedScreen)?.trim();
if (f != null && f == t) return false;
_lastNavigatedScreen = t;
_graph = recordNavigation(_graph, f, t, _now());
metrics.navigations++;
await serialize(kRoutesLogicalPath, _persistGraph);
_sync?.notifyDirty();
return true;
}