From c2f5a8df10ba6d9f4b44da229b018c697fb286e4 Mon Sep 17 00:00:00 2001 From: Faris Armoush Date: Sun, 13 Apr 2025 12:31:17 +0300 Subject: [PATCH] refactor: streamline context usage and improve readability in SidebarWidget --- .../all_spaces/widgets/sidebar_widget.dart | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) 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 482bb447..d241a9c1 100644 --- a/lib/pages/spaces_management/all_spaces/widgets/sidebar_widget.dart +++ b/lib/pages/spaces_management/all_spaces/widgets/sidebar_widget.dart @@ -12,6 +12,7 @@ import 'package:syncrow_web/pages/spaces_management/structure_selector/bloc/cent import 'package:syncrow_web/pages/spaces_management/structure_selector/bloc/center_body_event.dart'; import 'package:syncrow_web/utils/color_manager.dart'; import 'package:syncrow_web/utils/constants/assets.dart'; +import 'package:syncrow_web/utils/extension/build_context_x.dart'; import 'package:syncrow_web/utils/style.dart'; class SidebarWidget extends StatefulWidget { @@ -111,7 +112,7 @@ class _SidebarWidgetState extends State { children: [ Text( 'Communities', - style: Theme.of(context).textTheme.titleMedium?.copyWith( + style: context.textTheme.titleMedium?.copyWith( color: ColorsManager.blackColor, ), ), @@ -153,9 +154,7 @@ class _SidebarWidgetState extends State { } void _navigateToBlank(BuildContext context) { - setState(() { - _selectedId = ''; - }); + setState(() => _selectedId = ''); context.read().add( NewCommunityEvent(communities: widget.communities), ); @@ -194,14 +193,14 @@ class _SidebarWidgetState extends State { Widget _buildSpaceTile(SpaceModel space, CommunityModel community, {int depth = 1}) { - bool isExpandedSpace = _isSpaceOrChildSelected(space); + bool spaceIsExpanded = _isSpaceOrChildSelected(space); return Padding( padding: EdgeInsets.only(left: depth * 16.0), child: SpaceTile( title: space.name, key: ValueKey(space.uuid), isSelected: _selectedId == space.uuid, - initiallyExpanded: isExpandedSpace, + initiallyExpanded: spaceIsExpanded, onExpansionChanged: (expanded) {}, onItemSelected: () { setState(() {