common.dart 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * fluro
  3. * Created by Yakka
  4. * https://theyakka.com
  5. *
  6. * Copyright (c) 2019 Yakka, LLC. All rights reserved.
  7. * See LICENSE for distribution and usage details.
  8. */
  9. import 'package:flutter/widgets.dart';
  10. ///
  11. enum HandlerType {
  12. route,
  13. function,
  14. }
  15. ///
  16. class Handler {
  17. Handler({this.type = HandlerType.route, this.handlerFunc});
  18. final HandlerType type;
  19. final HandlerFunc handlerFunc;
  20. }
  21. ///
  22. typedef Route<T> RouteCreator<T>(
  23. RouteSettings route, Map<String, List<String>> parameters);
  24. ///
  25. typedef Widget HandlerFunc(
  26. BuildContext context, Map<String, List<String>> parameters);
  27. ///
  28. class AppRoute {
  29. String route;
  30. dynamic handler;
  31. TransitionType transitionType;
  32. AppRoute(this.route, this.handler, {this.transitionType});
  33. }
  34. enum TransitionType {
  35. native,
  36. nativeModal,
  37. inFromLeft,
  38. inFromRight,
  39. inFromBottom,
  40. fadeIn,
  41. custom, // if using custom then you must also provide a transition
  42. material,
  43. materialFullScreenDialog,
  44. cupertino,
  45. cupertinoFullScreenDialog,
  46. }
  47. enum RouteMatchType {
  48. visual,
  49. nonVisual,
  50. noMatch,
  51. }
  52. ///
  53. class RouteMatch {
  54. RouteMatch(
  55. {this.matchType = RouteMatchType.noMatch,
  56. this.route,
  57. this.errorMessage = "Unable to match route. Please check the logs."});
  58. final Route<dynamic> route;
  59. final RouteMatchType matchType;
  60. final String errorMessage;
  61. }
  62. class RouteNotFoundException implements Exception {
  63. final String message;
  64. final String path;
  65. RouteNotFoundException(this.message, this.path);
  66. @override
  67. String toString() {
  68. return "No registered route was found to handle '$path'";
  69. }
  70. }