Package selection guidance compiled from public package information, community data, and project usage.
Sailor is a Flutter package that simplifies navigation and routing in Flutter applications. It provides a clean, declarative way to define routes, manage page transitions with animations, and log navigation events for debugging and analytics. With Sailor, developers can easily navigate between pages, pass data between routes, and handle deep linking. The package integrates seamlessly into existing Flutter projects and supports both simple and complex routing needs. Its lightweight design and intuitive API make it ideal for apps requiring structured navigation patterns.
Use cases
Simple app navigation
Complex route management
Page transition animations
Navigation event logging
Deep linking support
Stateful route handling
Key features
Declarative route definitions
Built-in animation support
Navigation event logging
Easy data passing between routes
Support for deep linking
Minimal boilerplate
Suitable for
Beginner Flutter developers
Medium to large-scale Flutter apps
Apps needing detailed navigation tracking
Projects with complex routing logic
Teams prioritizing clean code structure
Considerations
Limited platform-specific customization
No built-in support for dynamic routes
Requires understanding of Flutter's widget tree
May need additional packages for advanced features
Not suitable for very lightweight apps with minimal navigation
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
sailor
A Flutter package for easy navigation management.
Warning: Package is still under development, there might be breaking changes in future.
TIP: Sailor is a callable class, so you can omit navigate and directly call the method.
Routes.sailor("/secondPage");
Passing Parameters
Sailor allows you to pass parameters to the page that you are navigating to.
Before passing the parameter itself, you need to declare it while declaring your route. Let's declare a parameter named id that has a default value of 1234.
classSecondPageextendsStatelessWidget{
@overrideWidgetbuild(BuildContext context) {
final id = Sailor.param<int>(context, 'id');
...
}
}
Make sure to specify the type of paramter when declaring SailorParam<T>. This type is used to make sure when the route is being opened, it is passed the correct param type. Right now Sailor logs a warning if the type of declared and passed param is not same. In future version this might throw an error.
Passing Arguments
Sailor allows you to pass arguments to the page that you are navigating to.
The result from each route guard is Future<bool>. If the value returned by each route is true the route is accepted and opened, anything else will result in route being rejected and not being opened.
Transitions
Sailor has inbuilt support for page transitions. A transition is specified using SailorTransition.
Transition can be specified at 3 levels (ordered in priority from highest to lowest):
When Navigating (using Sailor.navigate).
While adding routes (SailorRoute).
Global transitions (SailorOptions).
When navigating
Specify which transitions to use when calling the navigate method.
More than one transition can be provided when navigating a single route. These transitions are composed on top of each other, so in some cases changing the order will change the animation.
NOTE: Custom transitions have the highest priority, if you provide a custom transition, they will be used over Sailor's inbuilt transitions.
The same priority rules apply to custom transitions as inbuilt sailor transitions, with the added rule that at any step if both transitions are provided (i.e. Sailor's inbuilt transitions and a CustomSailorTransition), the custom transition will be used over inbuilt one.
For example, in the below code, MyCustomTransition will be used instead of SailorTransition.slide_from_top.
Use SailorLoggingObserver to log the push/pop navigation inside the application.
Add the SailorLoggingObserver to the navigatorObservers list inside your MaterialApp.