सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।
RouteFly एक फ़ोल्डर-आधारित रूट मैनेजमेंट पैकेज है, जो फ्लटर के लिए नेक्स्ट.जी से प्रेरित है, जिसका उद्देश्य फ्लटर एप्लिकेशन में नेविगेशन को सरल बनाना है। यह एक परिभाषित फ़ोल्डर संरचना से ऑटोमैटिक रूट उत्पन्न करता है, बॉयलरप्लेट को कम करता है और कोड संगठन को बेहतर बनाता है। फ्लटरंडो समुदाय द्वारा बनाया गया, यह सभी प्रमुख प्लेटफॉर्म जैसे Android, iOS, Web, macOS, Windows और Linux को सपोर्ट करता है। RouteFly विकासकर्ताओं की उत्पादकता को बढ़ावा देता है, जिससे हाथ से रूट रजिस्टर किए बिना सहज और स्केलेबल रूटिंग की अनुमति मिलती है।
उपयोग
फोल्डर संरचना से स्वचालित मार्ग उत्पन्न करें
बड़े Flutter ऐप में नेविगेशन को सरल बनाना
रूट लॉजिक के स्पष्ट अलगाव को सक्षम करना
बहु-प्लेटफॉर्म Flutter प्रोजेक्ट्स का समर्थन करना
टीम वातावरण में रूट प्रबंधन को सुगम बनाना
मुख्य विशेषताएँ
फ़ोल्डर-आधारित मार्ग परिभाषा
स्वचालित मार्ग उत्पादन
न्यूनतम बॉयलरप्लेट
प्लेटफॉर्म-समर्थन
Flutterando पारिस्थितिकी तंत्र के साथ एकीकरण
इनके लिए उपयुक्त
फ़ोल्डर-आधारित प्रोजेक्ट संरचना का उपयोग करने वाले विकासकर्ता
स्केलेबल रूटिंग समाधान की तलाश कर रहे टीमें
हाथ से रूट सेटअप कम करने का प्रयास करने वाले प्रोजेक्ट
Next.js नियमों के साथ परिचित Flutter विकासकर्ता
कई प्लेटफॉर्म के लिए लक्षित ऐप्स
विचार योग्य बातें
विशिष्ट फ़ोल्डर नामकरण अभ्यास का पालन करने की आवश्यकता है
जटिल रूट पैरामीटर्स के लिए विन्यास की आवश्यकता हो सकती है
संरचित डायरेक्टरी लेआउट वाले प्रोजेक्ट्स के लिए सबसे उपयुक्त
हाथ से रूट सेटअप की तुलना में सीमित कस्टमाइज़ेशन
Flutterando के रखरखावकर्ताओं पर निर्भर है अद्यतन के लिए
मूल README
संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।
Routefly
Routefly is a folder-based route manager inspired by NextJS and created by the Flutterando community. It allows you to automatically create routes in your Flutter app by simply organizing your code files within specific directories. When a file is added to the "pages" directory, it's automatically available as a route. Just add the appropriate folder structure inside the "lib/app" folder.
Example:
Sponsors
Installation and Initialization
To get started with Routefly, follow these steps:
Add the Routefly package to your Flutter project:
flutter pub add routefly
You will need to add the @Main() annotation to the main Widget (usually the one containing MaterialApp or CupertinoApp). After adding the necessary imports and parts, the code will be ready to generate the routes.
It is also necessary to use Navigator 2.0, accessed through the MaterialApp.router or CupertinoApp.router constructor, adding the custom routerConfig from Routefly:
Run this command every time you create a new folder with a page to generate the routes again. You can also use the --watch flag to automatically generate routes when adding a new page to a folder.
Route Groups
In the app directory, nested folders are normally mapped to URL paths. However, you can mark a folder as a Route Group to prevent the folder from being included in the route's URL path.
This allows you to organize your route segments and project files into logical groups without affecting the URL path structure.
A route group can be created by wrapping a folder's name in parenthesis: (folderName)
Routefly.navigate('path'): Replaces the entire route stack with the requested path. Routefly.pushNavigate('path'): Adds a new route on top of the existing stack. Routefly.push('path'): Adds a route to the route stack. Routefly.pop(): Removes the top route from the route stack. Routefly.replace('path'): Replaces the last route in the stack with the requested path.
You can use RELATIVE PATH also;
It is also possible to access routes using Record routePaths which replaces the strings
which represent the path by an object notation.
Dynamic Routes allow you to create routes from dynamic data. You can use dynamic segments enclosed in brackets, such as [id] or [slugs]. For example:
Create a page using a dynamic segment: lib/app/users/[id]/user_page.dart. This generates the route path /users/[id].
Use navigation commands to replace the dynamic segment, like Routefly.push('/users/2').
Access the dynamic parameter (id) on the page using Routefly.query['id'].
You can also access segment parameters using Routefly.query.params, e.g., Routefly.query.params['search'] for /product?search=Text.
Custom Transition
To create custom route transitions, define a routeBuilder function in your page file. This allows you to use custom transitions based on PageRouteBuilder. For example:
To create a layout, create the folder it will belong to and add a *_layout.dart file. The child folders must be inside the layout's parent folder.
In the Layout Widget, add RouterOutlet() wherever you prefer nested routes to appear.
ex:
RouterOutlet(),
Tip
If the error occurs:
EXCEPTION CAUGHT BY RENDERING LIBRARY
The following assertion was thrown during performResize().
This error usually occurs in lists, columns and rows when an element does not have a defined size. To fix it, you can use, for example, Expanded, Center or SizedBox. In this example, I chose to use Expanded.
When creating a route with name 404, it will be triggered when a page is not found.
Routefly gives the possibility to modify the default route for unfound pages.