Skip to content

Commit

Permalink
cleanup (#237)
Browse files Browse the repository at this point in the history
* cleanup class member order and example/pubspec assets order
  • Loading branch information
lukepighetti committed Jun 14, 2021
1 parent d0a7efc commit d326c32
Show file tree
Hide file tree
Showing 5 changed files with 222 additions and 131 deletions.
2 changes: 1 addition & 1 deletion README.md
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
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
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

0 comments on commit d326c32

Please sign in to comment.