navigation_history_observer
1.1.1, released 3 years ago by an unverified publisher
A Flutter NavigatorObserver that tracks pushed and popped navigation route history.
What it does
It records the navigation stack both forwards and backwards by acting as a NavigatorObserver. It exposes history lists as immutable collections and provides a stream to listen for navigation changes.
AI-written summary of version 1.1.1, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to track or inspect the user's navigation history throughout the app.
- You want to react to navigation stack changes via a stream.
Skip it when
- You are looking for advanced declarative routing features.
- You intend to rely on popped routes for forward navigation.
Strengths
- Singleton pattern allows access to history from anywhere in code.
- Provides an easy-to-use history change stream.
- Returns immutable BuiltLists to prevent unauthorized state manipulation.
Weaknesses
- Popped routes are already disposed, meaning you cannot simply navigate back to them directly.
- Singleton usage may complicate dependency injection or testing.
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 1
Add the NavigationHistoryObserver to your MaterialApp's navigatorObservers list.
void main() {
runApp(MaterialApp(
home: Container(),
navigatorObservers: [NavigationHistoryObserver()],
));
}Alternatives
Packages that do the same job and could replace navigation_history_observer.
- go_router
A declarative routing package built for Flutter that handles deep linking and complex navigation flows.
98Compare - auto_route
A declarative routing package that generates strongly-typed navigation code.
87Compare
Works with
Packages commonly used together with navigation_history_observer: ones it builds on, ones built on it, and its own family.