Refactor HomeCubit class for better instance management

Create a private static instance variable and refactor methods for better instance management in the HomeCubit class.
This commit is contained in:
Mohammad Salameh
2024-04-01 12:09:01 +03:00
parent a20dfa3709
commit d1bc973b38
10 changed files with 169 additions and 145 deletions

View File

@ -20,11 +20,9 @@ class DefaultAppBar extends StatelessWidget implements PreferredSizeWidget {
backgroundColor: Colors.transparent,
leadingWidth: 150,
toolbarHeight: Constants.appBarHeight,
leading: HomeCubit.spaces != null
? HomeCubit.spaces!.isNotEmpty
? HomeCubit.appBarLeading[
HomeCubit.bottomNavItems[HomeCubit.pageIndex].label]
: const Center(child: BodySmall(text: 'Create Home'))
leading: HomeCubit.getInstance().spaces!.isNotEmpty
? HomeCubit.appBarLeading[
HomeCubit.bottomNavItems[HomeCubit.pageIndex].label]
: null,
actions: HomeCubit.appBarActions[
HomeCubit.bottomNavItems[HomeCubit.pageIndex].label],