getChildSpaces method
- bool recursive = false,
Gets all child spaces of this space.
When recursive is true, traverses the space tree depth-first to
return every descendant as a Space model. This mirrors
Project.getSpaces to keep navigation consistent.
final children = await assets.getChildSpaces();
Implementation
Future<List<Space>> getChildSpaces({bool recursive = false}) async {
final spaceResponses = await client.getChildSpaces(path);
final spaces = spaceResponses.map<Space>((s) => Space(s, client)).toList();
if (recursive && spaces.isNotEmpty) {
final allSpaces = <Space>[...spaces];
for (final space in spaces) {
final children = await space.getChildSpaces(recursive: true);
allSpaces.addAll(children);
}
return allSpaces;
}
return spaces;
}