findDeclarationObject method

dynamic findDeclarationObject(
  1. List<String> segments
)

Finds declaration of query mappers for given segments list

Implementation

dynamic findDeclarationObject(List<String> segments) {
  Map currentMapOfSubRoutes = routeLinkHandlers;

  for (final segment in segments) {
    var handlersObject = currentMapOfSubRoutes[segment];

    handlersObject ??= currentMapOfSubRoutes['*'];

    if (handlersObject == null) {
      return null;
    }

    if (handlersObject is LinkHandler) {
      return handlersObject;
    }

    currentMapOfSubRoutes = handlersObject as Map;
  }

  return currentMapOfSubRoutes[''];
}