{"id":20664028,"url":"https://github.com/flutterando/routefly","last_synced_at":"2025-07-22T11:03:30.826Z","repository":{"id":199987193,"uuid":"704718955","full_name":"Flutterando/routefly","owner":"Flutterando","description":"Folder-based route manager inspired by NextJS and created by the Flutterando community.","archived":false,"fork":false,"pushed_at":"2025-06-13T18:33:57.000Z","size":793,"stargazers_count":61,"open_issues_count":9,"forks_count":13,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-06-13T19:37:04.691Z","etag":null,"topics":["dart","flutter"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/routefly","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Flutterando.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-10-13T22:45:07.000Z","updated_at":"2025-06-13T18:34:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"4e8bcc50-ac52-45f3-807f-528a3142cac5","html_url":"https://github.com/Flutterando/routefly","commit_stats":{"total_commits":54,"total_committers":4,"mean_commits":13.5,"dds":0.09259259259259256,"last_synced_commit":"3fd420d163777772a05e2987a42fb522a80a3ddd"},"previous_names":["flutterando/routefly"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Flutterando/routefly","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flutterando%2Froutefly","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flutterando%2Froutefly/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flutterando%2Froutefly/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flutterando%2Froutefly/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Flutterando","download_url":"https://codeload.github.com/Flutterando/routefly/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flutterando%2Froutefly/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266481732,"owners_count":23935938,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dart","flutter"],"created_at":"2024-11-16T19:21:45.310Z","updated_at":"2025-07-22T11:03:30.820Z","avatar_url":"https://github.com/Flutterando.png","language":"Dart","readme":"# Routefly\n\n![Logo](https://github.com/Flutterando/routefly/blob/main/assets/images/logo_with_text.png?raw=true)\n\nRoutefly 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.\n\n**Example:**\n\n![Logo](https://github.com/Flutterando/routefly/blob/main/assets/images/routefly_scheme.png?raw=true)\n\n## Sponsors\n\u003ca href=\"https://www.nzest.co/\"\u003e\n    \u003cimg src=\"https://media.discordapp.net/attachments/1328774070866673715/1349417416337391678/nZest-logo-2.png?ex=67d30667\u0026is=67d1b4e7\u0026hm=3e4c5e2a57a6dbe1463aa7d6fe8546c1dfa7ab67ff683bed13fa07ff88ffb58b\u0026=\u0026format=webp\u0026quality=lossless\u0026width=1723\u0026height=918\" alt=\"Logo\" width=\"200\"\u003e\n\u003c/a\u003e\n\n## Installation and Initialization\n\nTo get started with Routefly, follow these steps:\n\n1. Add the Routefly package to your Flutter project:\n\n```bash\n   flutter pub add routefly\n```\n\n2. 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.\n\nIt is also necessary to use Navigator 2.0, accessed through the `MaterialApp.router` or `CupertinoApp.router` constructor, adding the custom `routerConfig` from `Routefly`:\n\n\n```dart\n// file: my_app.dart\n\nimport 'package:routefly/routefly.dart';\nimport 'my_app.route.dart'; // \u003c- GENERATED\n\npart 'my_app.g.dart'; // \u003c- GENERATED\n\n@Main('lib/app')\nclass MyApp extends StatelessWidget {\n  @override\n  Widget build(BuildContext context) {\n    return MaterialApp.router(\n      routerConfig: Routefly.routerConfig(\n        routes: routes, // GENERATED\n      ),\n    );\n  }\n}\n```\n\nThe `@Main()` takes a parameter for the folder that will be used by `Routefly` as the base to look for pages.\nThe default base folder is `lib/app`;\n\n3. Organize your code by creating folders that contain a *_page.dart file for each page. \nFor example:\n\n```\n.\n└── app/\n    ├── product/\n    │   └── product_page.dart\n    └── user/\n        └── user_page.dart\n```\n\n4. Generate routes using the following command:\n```\ndart run routefly\n```\n\nRun 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.\n\n\n## Route Groups\n\nIn 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.\n\nThis allows you to organize your route segments and project files into logical groups without affecting the URL path structure.\n\nA route group can be created by wrapping a folder's name in parenthesis: `(folderName)`\n\n```\n.\n└── app/\n    ├── (product)/\n        └── home/\n            └── home_page.dart\n```\nGenerate =\u003e `/home`;\n\n## Navigation\n\nRoutefly provides simple navigation methods:\n\n`Routefly.navigate('path')`: Replaces the entire route stack with the requested path.\u003cbr\u003e\n`Routefly.pushNavigate('path')`: Adds a new route on top of the existing stack.\u003cbr\u003e\n`Routefly.push('path')`: Adds a route to the route stack. \u003cbr\u003e\n`Routefly.pop()`: Removes the top route from the route stack. \u003cbr\u003e\n`Routefly.replace('path')`: Replaces the last route in the stack with the requested path. \u003cbr\u003e\n\n**You can use `RELATIVE PATH` also**;\n\n\nIt is also possible to access routes using Record `routePaths` which replaces the strings\nwhich represent the `path` by an object notation.\n\n```dart\n// String notation\nRoutefly.navigate('/dashboard/users');\n\n// Object Notation\nRoutefly.navigate(routePaths.dashboard.users);\n```\n\n`Dynamic routes` are also represented by objects, but it is necessary to replace the dynamic parameters;\u003cbr\u003e\nUse the `changes()` method to do this;\n\n```dart\n// String notation =\u003e /product/[id]\nRoutefly.navigate('/product/1');\n\n// Object Notation =\u003e /product/[id]\nRoutefly.navigate(routePaths.product.changes({'id': '1'}));\n```\n\n\n## Dynamic Routes\n\nDynamic Routes allow you to create routes from dynamic data. You can use dynamic segments enclosed in brackets, such as `[id]` or `[slugs]`. For example:\n\nCreate a page using a dynamic segment: `lib/app/users/[id]/user_page.dart`. This generates the route path `/users/[id]`.\n\nUse navigation commands to replace the dynamic segment, like `Routefly.push('/users/2')`.\n\nAccess the dynamic parameter (id) on the page using `Routefly.query['id']`.\n\nYou can also access segment parameters using Routefly.query.params, e.g., `Routefly.query.params['search']` for `/product?search=Text`.\n\n\n## Custom Transition\n\nTo create custom route transitions, define a routeBuilder function in your page file. This allows you to use custom transitions based on PageRouteBuilder. For example:\n\n\n```dart\nRoute routeBuilder(BuildContext context, RouteSettings settings) {\n  return PageRouteBuilder(\n    settings: settings // \u003c- !! DON'T FORGET THAT !!\n    pageBuilder: (_, a1, a2) =\u003e const UserPage(),\n    transitionsBuilder: (_, a1, a2, child) {\n      return FadeTransition(opacity: a1, child: child);\n    },\n  );\n}\n```\n\nIt is also possible to change the global transition of the routes:\n\n```dart\n@override\n  Widget build(BuildContext context) {\n    return CupertinoApp.router(\n      routerConfig: Routefly.routerConfig(\n        routes: routes,\n        routeBuilder: (context, settings, child) {\n          return CupertinoPageRoute(\n            settings: settings, // !! IMPORTANT !!\n            builder: (context) =\u003e child,\n          );\n        },\n      ),\n    );\n  }\n```\n\n\n## Layout (RouterOutlet)\n\nLayout are pages that support nested navigation. All child routes to the layout will be pointed out as children in the navigation.\n\n```\n.\n└── app/\n    └── dashboard/\n        ├── users/\n        │   └── users_page.dart\n        ├── products/\n        │   └── products_page.dart\n        └── dashboard_layout.dart\n```\n\nTo 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.\n\nIn the Layout Widget, add `RouterOutlet()` wherever you prefer nested routes to appear.\nex:\n\n```dart\nRouterOutlet(),\n\n```\n### Tip\nIf the error occurs:\u003cbr\u003e\nEXCEPTION CAUGHT BY RENDERING LIBRARY \u003cbr\u003e\nThe following assertion was thrown during performResize().\n\nThis 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.\n\n```dart\nclass DashboardLayout extends StatelessWidget {\n  const DashboardLayout({super.key});\n\n  @override\n  Widget build(BuildContext context) {\n    return Scaffold(\n      body: SafeArea(\n        child: Column(\n          children: [\n            ListTile(\n              title: const Text('Option 1'),\n              onTap: () {\n                Routefly.navigate(routePaths.dashboard.products);\n              },\n            ),\n            ListTile(\n              title: const Text('Option 2'),\n              onTap: () {\n                Routefly.navigate(routePaths.dashboard.users);\n              },\n            ),\n            const Expanded(child: RouterOutlet()),\n          ],\n        ),\n      ),\n    );\n  }\n}\n\n```\n\n![Logo](https://github.com/Flutterando/routefly/blob/main/assets/images/nested_navigation.gif?raw=true)\n\n## Middleware\n\nMiddleware are functions that intercept the request and can change the route information and can cancel or redirect the route request.\n\n```dart\nFutureOr\u003cRouteInformation\u003e _guardRoute(RouteInformation routeInformation) {\n  if (routeInformation.uri.path == '/guarded') {\n    return routeInformation.redirect(Uri.parse('/'));\n  }\n\n  return routeInformation;\n}\n```\n\nNow add it to the initial configuration.\n\n```dart\nreturn MaterialApp.router(\n      routerConfig: Routefly.routerConfig(\n        routes: routes,\n        middlewares: [_guardRoute], // \u003c\u003c\u003c\u003c\n      ),\n    );\n```\n\n## Not found page (404)\n\nWhen creating a route with name `404`, it will be triggered when a page is not found.\n`Routefly` gives the possibility to modify the default route for unfound pages.\n\n```dart\nreturn MaterialApp.router(\n      routerConfig: Routefly.routerConfig(\n        routes: routes,\n        notFoundPath: '/not-found',\n      ),\n    );\n```\n![Logo](https://github.com/Flutterando/routefly/blob/main/assets/images/404.png?raw=true)\n\n\nIf you have any questions or need assistance with the package, feel free to reach out to the `Flutterando` community.\n\n**Happy routing with Routefly!**\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflutterando%2Froutefly","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflutterando%2Froutefly","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflutterando%2Froutefly/lists"}