Verwalten Sie die Seitennavigation/Routing in Flutter-Anwendungen einfach. Fügen Sie Seitentransitionsanimationen hinzu und protokollieren Sie Navigationsereignisse.
Aus öffentlichen Paketdaten erstellte Orientierung.
Sailor ist ein Flutter-Paket, das die Navigation und Routing in Flutter-Anwendungen vereinfacht. Es bietet eine saubere, deklarative Möglichkeit, Routen zu definieren, Seitenübergänge mit Animationen zu verwalten und Navigationsereignisse für Debugging und Analyse zu protokollieren. Mit Sailor können Entwickler problemlos zwischen Seiten navigieren, Daten zwischen Routen übergeben und Deep Linking behandeln. Das Paket lässt sich nahtlos in bestehende Flutter-Projekte integrieren und unterstützt sowohl einfache als auch komplexe Routing-Anforderungen. Sein leichtgewichtiges Design und seine intuitive API machen es ideal für Apps, die strukturierte Navigationsmuster erfordern.
Anwendungsfälle
Einfache App-Navigation
Komplexe Routenverwaltung
Seitenübergangsanimationen
Navigationsevent-Protokollierung
Unterstützung für Deep Linking
zustandsbehaftete Routenverwaltung
Hauptmerkmale
Deklarative Routendefinitionen
Eingebaute Animationsunterstützung
Navigationsevent-Protokollierung
Einfache Datenübertragung zwischen Routen
Unterstützung für Deep Linking
Minimales Boilerplate
Geeignet für
Anfänger-Flutter-Entwickler
Mittel- bis großskalige Flutter-Anwendungen
Apps, die eine detaillierte Navigationsverfolgung erfordern
Projekte mit komplexer Routing-Logik
Teams, die saubere Codestruktur priorisieren
Hinweise
Eingeschränkte plattformspezifische Anpassung
Keine integrierte Unterstützung für dynamische Routen
Kenntnis der Widget-Baum-Struktur von Flutter erforderlich
Möglicherweise sind zusätzliche Pakete für erweiterte Funktionen erforderlich
Nicht geeignet für sehr leichte Apps mit minimaler Navigation
Original-README
Originaler README-Schnappschuss aus dem verknüpften Quell-Repository. Aktuelle Inhalte finden Sie im Repository.
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.