parse_route

Last updated:

0 purchases

parse_route Image
parse_route Images
Add to Cart

Description:

parse route

ParseRoute Library #
Designed with efficiency and comprehensiveness in mind, ParseRoute delivers an all-encompassing solution for route parsing, matching, and navigation within Dart applications. Its intuitive API caters to developers by simplifying complex navigation management tasks, making it a highly flexible and scalable choice for integration into various applications and frameworks. Ideal for projects utilizing Navigator 2, or even in server-side Dart applications, ParseRoute is poised to become a foundational component of GetX and GetServer at some point in the future.


Key Features #

Dynamic Route Matching: Simplifies the matching of routes, including those with dynamic segments, and effortlessly extracts relevant parameters for use.
Query Parameter Parsing: Integrates the parsing of URL query parameters directly into the route matching workflow, enhancing data retrieval and usage.
Route Registration & Verification: Enables the easy registration of routes within your application and allows for the immediate verification of their registration status.
Nested Route Support: Facilitates the organization of complex application navigational structures through the use of nested routes.
Advanced Programmatic Navigation: Provides robust tools for programmatically managing navigation, leveraging both route and query parameters for seamless transitions.
Comprehensive History Management: Features a powerful history management system that supports back navigation, route replacement, and history clearing functionalities.

Getting Started #
To integrate ParseRoute into your Dart project, simply add it as a dependency in your project's pubspec.yaml file:
dependencies:
parse_route: ^<latest_version>
copied to clipboard
Ensure to replace <latest_version> with the latest version number of the library.
Basic Usage #
Setting Up #
Begin by importing ParseRoute into your project file:
import 'package:parse_route/parse_route.dart';
copied to clipboard
Register Routes #
Register your application's routes as follows:
final parser = ParseRoute();

// Register individual routes with dynamic segments
parser.registerRoute('/user/:id');
// Automatic tracking of nested routes
parser.registerRoute('/profile/followers');
parser.registerRoute('/profile/following');
parser.registerRoute('/profile/edit');
// Wildcard support
parser.registerRoute('/settings/*');
// Query parameter support
parser.registerRoute('/search?foo=bar&baz=qux');
// Dynamic segments can be registered with query parameters
parser.registerRoute('/user/:id?foo=bar');
copied to clipboard
Route Matching and Navigation #
Match a route and navigate through your application with ease:
final match = parser.matchRoute('/user/123?foo=bar');
if (match != null) {
// Access matched route and parameters
print(match.path); // /user/:id
print(match.parameters); // {id: '123'}
print(match.urlParameters); // {foo: 'bar'}
}

// Navigate to a route
parser.push('/profile/123');
// Check the current route
print(parser.current.fullPath); // /profile/123
copied to clipboard
Managing Navigation History #
Efficiently manage your navigation history:
// Navigate through routes
parser.push('/home');
parser.push('/profile/edit');
// Go back to the previous route
parser.pop();
// Verify the current route
print(parser.current.fullPath); // /home
copied to clipboard
Route Listeners #
parser.addListener('/profile', (newRoute, oldRoute, type) {
print('Profile route changed: ${newRoute.fullPath}');
});

parser.push('/profile/123'); // Triggers listener
copied to clipboard
Complex Routes #
parser.registerRouter('/project/:projectId/task/:taskId/detail');

final result = parser.matchRoute('/project/42/task/108/detail?foo=bar');
print(result?.parameters); // {projectId: 42, taskId: 108}
print(result?.urlParameters); // {foo: bar}
copied to clipboard
API Reference #
ParseRoute #

registerRouter(String path): Register a new route
matchRoute(String path): Match a given path to a registered route
push(String path): Navigate to a new route
pop(): Go back to the previous route
replaceLast(String path): Replace the current route
addListener(String path, RouteListener listener): Add a listener for route changes
removeListener(String path): Remove a route listener

MatchResult #

path: The matched route path
cleanPath: The actual path without query parameters
parameters: Map of route parameters
urlParameters: Map of URL query parameters

Contribution and Support #
We welcome contributions to the ParseRoute library with open arms! If you're interested in contributing, please submit a pull request with your proposed changes. For any questions, suggestions, or issues, feel free to open an issue on our GitHub repository. Your input helps make ParseRoute better.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.