build method

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

Implementation

@override
Widget build(BuildContext context, WidgetRef ref) {
  //Get my events data
  final calEventsLoader = switch (eventFilters) {
    EventFilters.ongoing => ref.watch(myOngoingEventListProvider(null)),
    _ => ref.watch(myUpcomingEventListProvider(null)),
  };
  final sectionTitle = switch (eventFilters) {
    EventFilters.ongoing => L10n.of(context).happeningNow,
    _ => L10n.of(context).myUpcomingEvents,
  };

  return calEventsLoader.when(
    data: (calEvents) {
      if (calEvents.isEmpty) return const SizedBox.shrink();
      return Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          sectionHeader(context, sectionTitle),
          eventListUI(context, calEvents),
        ],
      );
    },
    error: (e, s) {
      _log.severe('Failed to load cal events', e, s);
      return Text(L10n.of(context).loadingEventsFailed(e));
    },
    loading: () => const EventListSkeleton(),
  );
}