fromJson method

AppRoutePath fromJson(
  1. Map<String, dynamic> json
)

Returns an AppRoutePath object for a Json object.

Implementation

AppRoutePath fromJson(Map<String, dynamic> json) {
  AppRoutePath route;

  String? path;
  final dynamic value = json['path'];

  if (value is String) {
    path = value;
  } else {
    path = '';
  }

  if (path.trim().isEmpty) {
    path = '/404';
  }

  switch (path) {
    case '/':
      route = AppRoutePath.home();
      break;
    case '/404':
      route = AppRoutePath.unknown();
      break;
    default:
      route = AppRoutePath.page(path);
  }
  return route;
}