diff --git a/lib/pages/spaces_management/all_spaces/widgets/sidebar_widget.dart b/lib/pages/spaces_management/all_spaces/widgets/sidebar_widget.dart index d241a9c1..1e6b2bf5 100644 --- a/lib/pages/spaces_management/all_spaces/widgets/sidebar_widget.dart +++ b/lib/pages/spaces_management/all_spaces/widgets/sidebar_widget.dart @@ -113,8 +113,8 @@ class _SidebarWidgetState extends State { Text( 'Communities', style: context.textTheme.titleMedium?.copyWith( - color: ColorsManager.blackColor, - ), + color: ColorsManager.blackColor, + ), ), GestureDetector( onTap: () => _navigateToBlank(context), @@ -183,23 +183,30 @@ class _SidebarWidgetState extends State { onExpansionChanged: (title, expanded) {}, children: hasChildren ? community.spaces - .where((space) => (space.status != SpaceStatus.deleted || - space.status != SpaceStatus.parentDeleted)) - .map((space) => _buildSpaceTile(space, community)) + .where((space) { + final isDeleted = space.status != SpaceStatus.deleted; + final isParentDeleted = space.status != SpaceStatus.parentDeleted; + return (isDeleted || isParentDeleted); + }) + .map((space) => _buildSpaceTile(space: space, community: community)) .toList() : null, ); } - Widget _buildSpaceTile(SpaceModel space, CommunityModel community, - {int depth = 1}) { + Widget _buildSpaceTile({ + required SpaceModel space, + required CommunityModel community, + int depth = 1, + }) { bool spaceIsExpanded = _isSpaceOrChildSelected(space); + final isSelected = _selectedId == space.uuid; return Padding( padding: EdgeInsets.only(left: depth * 16.0), child: SpaceTile( title: space.name, key: ValueKey(space.uuid), - isSelected: _selectedId == space.uuid, + isSelected: isSelected, initiallyExpanded: spaceIsExpanded, onExpansionChanged: (expanded) {}, onItemSelected: () { @@ -212,11 +219,14 @@ class _SidebarWidgetState extends State { SelectSpaceEvent(selectedCommunity: community, selectedSpace: space), ); }, - children: space.children.isNotEmpty - ? space.children - .map((childSpace) => _buildSpaceTile(childSpace, community)) - .toList() - : [], + children: space.children + .map( + (childSpace) => _buildSpaceTile( + space: childSpace, + community: community, + ), + ) + .toList(), ), ); }