Pakete, Repositories und App-Kategorien suchen

Paketdetailsv1.1.1

navigation_history_observer

Ein Flutter NavigatorObserver, der eine Sammlung aus verfolgten Routengeschichten sowie aus entfernten Geschichten speichert.

AndroidiOSWebmacOSWindowsLinux
30-Tage-Downloads
31.300
Likes
70
Pub-Punkte
160

Paket installieren

flutter pub add navigation_history_observer

Paketübersicht

Aus öffentlichen Paketdaten erstellte Orientierung.

navigation_history_observer ist ein Flutter NavigatorObserver, der die Historie von hinzugefügten und entfernten Routen während der Navigation verfolgt und speichert. Er ermöglicht Entwicklern den Zugriff auf den vollständigen Navigationsfluss und unterstützt Funktionen wie die Anpassung des Rück-Button-Verhaltens, Analysen oder das Debuggen von Navigationsmustern. Der Observer erfasst Routenübergänge in Echtzeit auf allen unterstützten Plattformen, einschließlich Mobilgeräte, Web und Desktop. Er integriert sich nahtlos in das Routing-System von Flutter und erfordert nur minimale Einrichtung über den pub add-Befehl.

Anwendungsfälle

  • Debugging von Navigationsflüssen
  • Benutzerdefinierte Rückwärtsnavigation logik implementieren
  • Verfolgung der Benutzerreise für Analysen
  • Navigationssstatus nach App-Neustart wiederherstellen
  • Echtzeitüberwachung von Routenübergängen

Hauptmerkmale

  • Verfolgt sowohl gesendete als auch entfernte Routen
  • Bietet vollständige Navigationsverlauf
  • Plattformübergreifende Unterstützung (Android, iOS, Web, macOS, Windows, Linux)
  • Einfache Integration mit Navigator
  • Echtzeit-Überwachung von Routenänderungen

Geeignet für

  • Entwickler, die komplexe Navigationsabläufe erstellen
  • Apps, die detaillierte Navigationsanalysen erfordern
  • Teams, die benutzerdefinierte Navigationsverhalten implementieren
  • Debugging von routenbezogenen Problemen
  • Anwendungen, die eine Zustandswiederherstellung erfordern

Hinweise

  • Kann den Speicherverbrauch bei tiefen Navigationsstapeln erhöhen
  • Benötigt manuelle Verwaltung von Historiedaten
  • Nicht geeignet für leichte Navigationsanforderungen
  • Beschränkt auf die Verwendung mit MaterialApp oder CupertinoApp
  • Sollte ordnungsgemäß bei Navigator-Beobachtern registriert werden

Original-README

Originaler README-Schnappschuss aus dem verknüpften Quell-Repository. Aktuelle Inhalte finden Sie im Repository.

Flutter Navigation History Observer

A flutter navigation observer that adds access to lists that track the navigation stack both forwards and backwards.

Usage

This is a singleton, meaning you can access its single instance from anywhere by calling the default constructor.

To initialize the first instance you must add it to your app's navigator observers list like so:

void main() {
  runApp(MaterialApp(
    home: Container(),
    navigatorObservers: [NavigationHistoryObserver()],
  ));
}
History:

To access the history, use NavigationHistoryObserver().history from anywhere in your code.

Use NavigationHistoryObserver().top to peek on the navigation stack's top element - which would be the current route.

Popped routes (forwards history):

To access the popped routes, use NavigationHistoryObserver().poppedRoutes from anywhere in your code.

UseNavigationHistoryObserver().next to get the most recent popped route.

This feature is intended to track the pages visited by the user, rather than navigating forwards. Please keep in mind that popped routes have already been disposed, meaning that you can't simply navigate to them as is via Navigator.push(context, route).

If you'd still like to navigate forwards, you may try Navigator.pushNamed(context, name), whereas the name should be extracted from route.settings.name provided that you're using named routes in your app.
However, there's no guarantee that it'll work.

Nevertheless, I discourage having forwards-navigation in your app.

History Change Stream:

The NavigationHistoryObserver class holds a StreamController that broadcasts each time the navigation stack changes.

Use NavigationHistoryObserver().historyChangeStream.listen((change) => action) to listen for changes.

The change object is of type HistoryChange. It holds the following properties:

  1. action - a NavigationStackAction enum reporting the action that caused this change. Values: push, pop, remove, replace.
  2. newRoute - the new route that was added/removed from the stack.
  3. oldRoute - the old route that was in place before this action happened.

This provides you with an easy-to-use interface that allows updating states across your app whenever the navigation stack changes. See the example for basic usage.

Developer's Note:

The history and poppedRoutes getters return clones of the actual private collections as BuiltLists, meaning they're immutable. To change these collections, use the default Navigator as you normally would, and they'll update as you navigate throughout your app.

Special Thanks

  • Shoutout to the Flutter Israel Developers community for being supportive and encouraging me to create this package.
  • Special thanks to Sahar Vanunu for giving me the original idea for this package.

Kategorien

Abhängigkeiten

Abhängigkeiten 1 Einträge

Quell-Repository

Projekte, die dieses Paket verwenden

Noch keine Daten verfügbar.