buildMessagesList method

Widget buildMessagesList(
  1. BuildContext context,
  2. List messages
)

Implementation

Widget buildMessagesList(BuildContext context, List<dynamic> messages) {
  Widget loadingIndicator = CircularProgressIndicator.adaptive();

  if (messages.isEmpty) {
    if (tabName == 'all') {
      return buildEmptyList('No notifications', context);
    }
    return buildEmptyList('No $tabName notifications', context);
  }

  return ListView.builder(
    controller: scrollController,
    itemCount: messages.length + 1,
    itemBuilder: (context, index) {
      if (index < messages.length) {
        return buildListTile(context, messages[index]);
      } else {
        switch (tabName) {
          case 'all':
            if (index < fynoInApp.fynoInAppState.count) {
              return loadingIndicator;
            }
          case 'unread':
            if (index < fynoInApp.fynoInAppState.unreadCount) {
              return loadingIndicator;
            }
        }
      }
      return null;
    },
  );
}