diff --git a/lib/pages/space_management_v2/main_module/helpers/spaces_recursive_helper.dart b/lib/pages/space_management_v2/main_module/helpers/spaces_recursive_helper.dart index e751e8d8..b725bf31 100644 --- a/lib/pages/space_management_v2/main_module/helpers/spaces_recursive_helper.dart +++ b/lib/pages/space_management_v2/main_module/helpers/spaces_recursive_helper.dart @@ -7,13 +7,15 @@ abstract final class SpacesRecursiveHelper { SpaceDetailsModel updatedSpace, ) { return spaces.map((space) { - if (space.uuid == updatedSpace.uuid) { + final isUpdatedSpace = space.uuid == updatedSpace.uuid; + if (isUpdatedSpace) { return space.copyWith( spaceName: updatedSpace.spaceName, icon: updatedSpace.icon, ); } - if (space.children.isNotEmpty) { + final hasChildren = space.children.isNotEmpty; + if (hasChildren) { return space.copyWith( children: recusrivelyUpdate(space.children, updatedSpace), ); @@ -26,7 +28,7 @@ abstract final class SpacesRecursiveHelper { List spaces, String spaceUuid, ) { - final s = spaces.map((space) { + final updatedSpaces = spaces.map((space) { if (space.uuid == spaceUuid) return null; if (space.children.isNotEmpty) { return space.copyWith( @@ -35,7 +37,7 @@ abstract final class SpacesRecursiveHelper { } return space; }).toList(); - - return s.whereType().toList(); + final nonNullSpaces = updatedSpaces.whereType().toList(); + return nonNullSpaces; } }