pathkit 0.0.1-dev.1 copy "pathkit: ^0.0.1-dev.1" to clipboard
pathkit: ^0.0.1-dev.1 copied to clipboard

A type-safe and flexible routing solution for Flutter applications that provides a clean API for handling navigation, route parameters, and nested routing scenarios.

Pathkit #

A type-safe and flexible routing solution for Flutter applications that provides a clean API for handling navigation, route parameters, and nested routing scenarios.

Features #

  • 🎯 Type-safe routing: Define routes with strongly typed parameters and arguments
  • 🔄 Path and query parameters: Support for both path parameters and query parameters
  • 📱 Navigator 2.0: Built on top of Flutter's Navigator 2.0 for complete control over the navigation stack
  • 🎨 Clean API: Intuitive and easy-to-use API for defining and handling routes
  • 📦 Nested routing: Support for nested navigation and complex routing scenarios
  • Performance: Efficient routing implementation with minimal overhead

Getting Started #

Add Pathkit to your pubspec.yaml:

dependencies:
  pathkit: ^0.0.1-dev.1

Usage #

Basic Routing #

Here's a simple example of how to set up basic routing with Pathkit:

MaterialApp.router(
  routerConfig: PathkitRouter(
    initialLocation: '/',
    routes: [
      PathkitRoute.withDefaultArgs(
        '/',
        (context, args) => const HomePage(),
      ),
      PathkitRoute.withDefaultArgs(
        '/about',
        (context, args) => const AboutPage(),
      ),
    ],
  ),
)

Navigate to routes using the Pathkit extension:

// Navigate to a route
context.pathkit.push('/about');

// Go back
context.pathkit.pop();

Typed Parameters #

Pathkit supports type-safe route parameters:

// Define route arguments
class UserRouteArgs {
  final String id;
  final String? tab;

  const UserRouteArgs({required this.id, this.tab});
}

// Define route with typed parameters
PathkitRoute.from<UserRouteArgs>(
  '/user/:id',
  (context, args) => UserPage(args: args),
  (pathParams, queryParams) => UserRouteArgs(
    id: pathParams['id']!,
    tab: queryParams['tab'],
  ),
)

Nested Routing #

Implement nested navigation structures easily:

PathkitRoute.from<TabRouteArgs>(
  '/dashboard/:tab',
  (context, args) => DashboardPage(currentTab: args.tab),
  (pathParams, queryParams) => TabRouteArgs(tab: pathParams['tab']!),
)

See the /example folder for complete examples of:

  • Basic routing
  • Typed parameters
  • Nested routing
  • Complex navigation patterns

Additional Information #

Documentation #

For detailed documentation and advanced usage examples, visit our GitHub repository.

Contributing #

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

License #

This project is licensed under the MIT License - see the LICENSE file for details.

0
likes
160
points
2
downloads

Publisher

unverified uploader

Weekly Downloads

A type-safe and flexible routing solution for Flutter applications that provides a clean API for handling navigation, route parameters, and nested routing scenarios.

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

collection, equatable, flutter, meta, path

More

Packages that depend on pathkit