build method

  1. @override
dynamic build(
  1. dynamic context,
  2. dynamic ref
)

Implementation

@override
Widget build(BuildContext context, WidgetRef ref) {
  //Common variable declaration
  final lang = L10n.of(context);

  //Get spaces List Data
  final allSpacesList = ref.watch(spacesProvider);
  final bookmarkedSpacesList = ref.watch(bookmarkedSpacesProvider);

  //Empty State
  if (allSpacesList.isEmpty) return const _NoSpacesWidget();

  //Bookmarked Spaces : If available
  if (bookmarkedSpacesList.isNotEmpty) {
    return SpaceListWidget(
      spaceListProvider: bookmarkedSpacesProvider,
      showSectionHeader: true,
      isShowSeeAllButton: true,
      showSectionBg: false,
      showBookmarkedIndicator: false,
      sectionHeaderTitle: lang.bookmarkedSpaces,
      onClickSectionHeader: () => context.pushNamed(Routes.spaces.name),
    );
  }

  //All Spaces : If bookmark list is empty
  final count =
      limit.map((val) => min(val, allSpacesList.length)) ??
      allSpacesList.length;
  return SpaceListWidget(
    spaceListProvider: spacesProvider,
    showSectionHeader: true,
    sectionHeaderTitle: lang.mySpaces,
    limit: limit,
    showSectionBg: false,
    isShowSeeAllButton: count != allSpacesList.length,
    onClickSectionHeader: () => context.pushNamed(Routes.spaces.name),
  );
}