Last updated:
0 purchases
routemaster conductor
Routemaster Conductor #
Routemaster Conductor was built to mimic how Next.js
does its routing, with routemaster's path param, nested routes and
route map switching. The main goal is to maintain the interface that Routemaster provides and help with generating the
boilerplate.
We don't depend on routemaster we just provide first party support, the filesystem paths are generated and assigned
to helper classes we also generate that provide a named route functionality.
Table of Contents #
Routemaster Conductor
Table of Contents
Motivation
Getting started
Install
Project structure
Folders
Files
Example
Configuration
Features
Partial support
Dynamic routes
404/Unknown routes
Templates
Routemaster
template.dart
404.dart
nested.dart
Motivation #
Thought it was an interesting concept and my paths are generally the same as the folder structure; and there are enough
navigation frameworks already.
Getting started #
Install #
flutter pub add dev:build_runner dev:routemaster_conductor
copied to clipboard
If you want routemaster
flutter pub add dev:build_runner dev:routemaster_conductor routemaster
copied to clipboard
Project structure #
We check for pages in .../pages/... and .../page/..., we don't really care where you put them in your project. The
routes will get placed in lib/src/routes.g.dart though. (See configuration for override option)
Folders
Folder
Type
Example
Route
pages/<dir>/
Segment
pages/home/page.dart
/home
pages/[key]/
Slug
pages/user/[id]/page.dart
/user/:id
pages/(name)/
Group
pages/(admin)/dashboard/page.dart
/dashboard
Files
File
Type
Description
page.dart
Page
Used to define a page for a give route
template.dart
Template
Used to override the default RouteSettings factory that routemaster uses
404.dart,unknown.dart
Unknown
Used to define a 404 page for the current route map. Its recommended to place one in each group.
tabs.dart,nested.dart
Nested
Used to define a nested route, or tabbed route.
Note: Templates will cascade down the file tree until another template is found.
Example
You can check the example/ folder for usage there is an example of each supported feature
Configuration #
# build.yaml
targets:
$default:
builders:
routemaster_conductor:
options:
routeMetaComment: true
framework: routemaster
copied to clipboard
Option
Description
Default
Allowed values
Nullable
routeMetaComment
Disables generating metadata comments on routes
true
true,false
true
framework
Generates different route maps depending on the framework. null will generate only the named routes
'routemaster'
'routemaster',null
true
outputDir
Overwrites the default output directory of rouets.g.dart
lib/src
Any valid path relative to project root
true
Features #
Generate routes from file system
Allow for dynamic routes with route slugs
Route grouping
This is similar to Next.js' grouping
except we generate a new route map for each group
This is to allow for routemaster's route map swapping
404/Unknown routes
Nested Routes/Tabs
Partial support #
Redirect
We sort of support this feature through templates
Might change in future
Dynamic routes #
When it comes to dynamic route slugs you can add a String params to your constructor of your page, and we will assume
the constructor param is the same as the slug id in the path, don't worry about optional, named and required params we
should handle all of them.
You don't need to use the constructor method at all you can also access it through routemaster.
404/Unknown routes #
Each route group has its own 404-page by default the routemaster one is used. These work similar to templates.
Templates #
Routemaster #
These templates are specific to the routemaster builder
template.dart
RouteSettings routeTemplate(RouteData routeData, Widget child) {
return //Your code here
}
copied to clipboard
404.dart
RouteSettings unknownRoute(String path) {
return //Your code here
}
copied to clipboard
nested.dart
The page in the same directory as the nested route will ignore the template, but the template will get applied to
subpages.
RouteSettings nestedRoute(RouteData routeData, Widget child) {
return //Your code here
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.