Skip to content

Instantly share code, notes, and snippets.

@marcinOz
Last active February 14, 2019 07:27
Show Gist options
  • Save marcinOz/48d40aee3a85ab01235b9f62582c12f8 to your computer and use it in GitHub Desktop.
Save marcinOz/48d40aee3a85ab01235b9f62582c12f8 to your computer and use it in GitHub Desktop.
final navigationReducer = combineReducers<List<String>>([
TypedReducer<List<String>, NavigateReplaceAction>(_navigateReplace),
TypedReducer<List<String>, NavigatePushAction>(_navigatePush),
TypedReducer<List<String>, NavigatePopAction>(_navigatePop),
]);
List<String> _navigateReplace(
List<String> route, NavigateReplaceAction action) =>
[action.routeName];
List<String> _navigatePush(List<String> route, NavigatePushAction action) {
var result = List<String>.from(route);
result.add(action.routeName);
return result;
}
List<String> _navigatePop(List<String> route, NavigatePopAction action) {
var result = List<String>.from(route);
if (result.isNotEmpty) {
result.removeLast();
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment