riverpod_navigator 0.3.0 riverpod_navigator: ^0.3.0 copied to clipboard
Simple but powerfull Flutter navigation with riverpod, freezed and Navigator 2.0.
Navigator for Riverpod #
Simple but powerfull navigation library (based on Flutter Navigator 2.0, Riverpod, and Freezed) that solves the following problems: #
- Strictly typed navigation:
You can usenavigate([Home(), Books(), Book(id: bookId)]);
instead ofnavigate('home/books/$bookId');
in your code. - Easier coding:
The problem of navigation is reduced to manipulation an immutable collection. - Better separation of concerns: UI x Model (thanks to riverpod 👍):
Navigation logic can be developed and tested without typing a single flutter widget. - Asynchronous navigation:
Prepare all necessary asynchronous operations before the navigation starts, e.g.- save data from the previous screen
- loading data for new screen
- Dependence on external providers:
The navigation state may also depend on external providers, e.g. user login status - Possibility to configure many navigation parameters, e.g. Page builder, Navigator builder, Splash screen
The mission #
Let's look at the following concepts:
- [string path], e.g
stringPath = 'home/books/book;id=2';
- string segment (the string path consists of three string segments), e.g. 'home', 'books', 'book;id=2'
- [typed path], e.g.
typedPath = <TypedSegment>[HomeSegment(), BooksSegment(), BookSegment(id:2)];
- typed segment, e.g. HomeSegment(), BooksSegment(), BookSegment()
- [navigation stack] of Flutter Navigator 2.0. e.g.
HomeScreen(HomeSegment())) => BooksScreen(BooksSegment()) => BookScreen(BookSegment(id:3))
The mission of navigation is to keep
[string path] <=> [typed path] <=> [navigation stack]
always in a synchronous state.