pheasant_router 0.0.1-pr copy "pheasant_router: ^0.0.1-pr" to clipboard
pheasant_router: ^0.0.1-pr copied to clipboard

The Pheasant Framework Routing Package, for single-page and server-side routing of your pheasant applications.

The Pheasant Routing Package #

This is the pheasant routing package, a plugin package for the Pheasant Framework used in routing web pages.

It makes use of the deno routing package under the hood to allow for more powerful and configurable routing on your web pages.

Using This Plugin #

The main functionality provided by this plugin is the Router and SPARouter, which is used for routing your applications, as well as being able to handle dynamic routes and get information from routes like dynamic route variables, queries etc.

final router = Router();

// Add routes to the router.
router.get('/', (req) {
    print("Hello World")
});

router.get('/:id', (req) {
    print(req.params.id);
});

// Initialise the router
router.init();

The request object req contains information about the route changes like the current path (req.path), queries (req.query), hashes (req.hash) and parameters (req.params).

The preferred router to use for your applications, especially if they are not to be server rendered, is the SPARouter.

final router = SPARouter();

// Note that you will need to know the state when changing routes
router.get('/', (req, state) {
    print("Hello World");
});

router.get('/:id', (req, state) {
    print("${req.params.id} -- ${state.name}");
});

// Initialise the router
router.init();

It also provides the PheasantRouterApp, which enables support for routing in your web applications.

import 'package:pheasant/pheasant.dart';
import 'package:pheasant_router/pheasant_router.dart';

void main() {
    final app = PheasantRouterApp(App);
    final router = SPARouter();

    // Router code

    app.router(router);
    app.build();
}

Versions #

Dart Package: TBD

Deno Package: Custom badge Custom Badge

2
likes
150
pub points
0%
popularity

Publisher

verified publishertech.nugegroup.com

The Pheasant Framework Routing Package, for single-page and server-side routing of your pheasant applications.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

pheasant

More

Packages that depend on pheasant_router