Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup #237

Merged
merged 6 commits into from
Jun 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The brightest, hippest, coolest router for Flutter.
- Querystring parameter parsing
- Common transitions built-in
- Simple custom transition creation
- Follows `beta` Flutter channel
- Follows `stable` Flutter channel
- Null-safety

## Example Project
Expand Down
4 changes: 2 additions & 2 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ flutter:
uses-material-design: true

assets:
- assets/images/logo_fluro.png
- assets/images/acc_boom.png
- assets/images/ic_result_hz.png
- assets/images/ic_function_hz.png
- assets/images/ic_result_hz.png
- assets/images/ic_transform_custom_hz.png
- assets/images/ic_transform_fade_in_hz.png
- assets/images/ic_transform_fade_out_hz.png
- assets/images/ic_transform_global_hz.png
- assets/images/ic_transform_native_hz.png
- assets/images/logo_fluro.png

fonts:
- family: Lazer84
Expand Down
40 changes: 30 additions & 10 deletions lib/src/common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,44 @@ enum HandlerType {

/// The handler to register with [FluroRouter.define]
class Handler {
Handler({this.type = HandlerType.route, required this.handlerFunc});
Handler({
this.type = HandlerType.route,
required this.handlerFunc,
});

final HandlerType type;
final HandlerFunc handlerFunc;
}

/// A function that creates new routes.
typedef Route<T> RouteCreator<T>(
RouteSettings route, Map<String, List<String>> parameters);
RouteSettings route,
Map<String, List<String>> parameters,
);

/// Builds out a screen based on string path [parameters] and context.
///
/// Note: you can access [RouteSettings] with the [context.settings] extension
typedef Widget? HandlerFunc(
BuildContext? context, Map<String, List<String>> parameters);
BuildContext? context,
Map<String, List<String>> parameters,
);

/// A route that is added to the router tree.
class AppRoute {
AppRoute(
this.route,
this.handler, {
this.transitionType,
this.transitionDuration,
this.transitionBuilder,
});

String route;
dynamic handler;
TransitionType? transitionType;
Duration? transitionDuration;
RouteTransitionsBuilder? transitionBuilder;
AppRoute(this.route, this.handler,
{this.transitionType, this.transitionDuration, this.transitionBuilder});
}

/// The type of transition to use when pushing/popping a route.
Expand Down Expand Up @@ -72,20 +86,26 @@ enum RouteMatchType {

/// The route that was matched.
class RouteMatch {
RouteMatch(
{this.matchType = RouteMatchType.noMatch,
this.route,
this.errorMessage = "Unable to match route. Please check the logs."});
RouteMatch({
this.matchType = RouteMatchType.noMatch,
this.route,
this.errorMessage = "Unable to match route. Please check the logs.",
});

final Route<dynamic>? route;
final RouteMatchType matchType;
final String errorMessage;
}

/// When the route is not found.
class RouteNotFoundException implements Exception {
RouteNotFoundException(
this.message,
this.path,
);

final String message;
final String path;
RouteNotFoundException(this.message, this.path);

@override
String toString() {
Expand Down
Loading