Gerencie facilmente a navegação / roteamento de páginas em aplicativos Flutter. Adicione animações de transição de página e registre eventos de navegação.
Orientação gerada a partir de informações públicas. Apenas para referência.
Sailor é um pacote Flutter que simplifica a navegação e roteamento em aplicativos Flutter. Ele fornece uma maneira limpa e declarativa de definir rotas, gerenciar transições de páginas com animações e registrar eventos de navegação para depuração e análise. Com o Sailor, os desenvolvedores podem navegar facilmente entre páginas, passar dados entre rotas e lidar com links profundos. O pacote se integra perfeitamente a projetos Flutter existentes e suporta necessidades simples e complexas de roteamento. Seu design leve e API intuitiva tornam-no ideal para aplicativos que exigem padrões estruturados de navegação.
Casos de uso
Navegação simples do aplicativo
Gerenciamento de rota complexa
Animações de transição de página
Registro de eventos de navegação
Suporte a linkagem profunda
manipulação de rota com estado
Principais recursos
Definições declarativas de rota
Suporte embutido a animação
Registro de eventos de navegação
Passagem fácil de dados entre rotas
Suporte para links profundos
Boilerplate mínimo
Indicado para
Desenvolvedores iniciantes do Flutter
Aplicativos Flutter de médio a grande porte
Aplicativos que precisam de rastreamento detalhado de navegação
Projetos com lógica de roteamento complexa
Equipes priorizando estrutura de código limpo
Considerações
Personalização específica de plataforma limitada
Sem suporte embutido para rotas dinâmicas
Requer conhecimento da árvore de widgets do Flutter
Pode ser necessário pacotes adicionais para recursos avançados
Não adequado para aplicativos muito leves com navegação mínima
README original
Snapshot do README original do repositório-fonte vinculado. Consulte o repositório para o conteúdo mais recente.
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.