scopeToMap static method

  1. @visibleForTesting
Map<String, dynamic> scopeToMap(
  1. ZenScope scope
)

Convert a scope and its children to a map recursively matching ScopeData.fromJson.

Implementation

@visibleForTesting
static Map<String, dynamic> scopeToMap(ZenScope scope) {
  final breakdown = ZenScopeInspector.getDependencyBreakdown(scope);
  String kind = 'page';
  if (scope.parent == null) {
    kind = 'root';
  } else if (scope.name?.toLowerCase().contains('module') == true) {
    kind = 'module';
  }

  return {
    'id': scope.id,
    'name': scope.name ?? 'Unnamed',
    'kind': kind,
    'parentId': scope.parent?.id,
    'parentName': scope.parent?.name,
    'isDisposed': scope.isDisposed,
    'isRoot': scope.parent == null,
    'controllers': breakdown['controllers'] ?? [],
    'services': breakdown['services'] ?? [],
    'others': breakdown['others'] ?? [],
    'children': scope.childScopes.map(scopeToMap).toList(),
  };
}