getList method

Widget getList(
  1. BuildContext context,
  2. TextEditingController textEditingController
)

Implementation

Widget getList(
    BuildContext context, TextEditingController textEditingController) {
  CometChatTheme theme = cometChatTheme;

  return Container(
    constraints: BoxConstraints(
      maxHeight: suggestions.length > 4
          ? 220
          : suggestions.isEmpty
              ? 50
              : suggestions.length * 55.0,
    ),
    decoration: BoxDecoration(
      color: theme.palette.backGroundColor.light,
      border: Border(
          top: BorderSide(color: theme.palette.getAccent100(), width: .72)),
    ),
    child: ListView.separated(
      controller: _controller,
      itemCount: hasMore ? suggestions.length + 1 : suggestions.length,
      itemBuilder: (context, index) {
        if (hasMore && index >= suggestions.length) {
          for (var element in _formatters) {
            if (_currentSearchKeyword != null &&
                _currentSearchKeyword!.isNotEmpty &&
                element.trackingCharacter == _currentSearchKeyword![0]) {
              element.onScrollToBottom(textEditingController);
            }
          }

          return const SizedBox();
        }

        return index < suggestions.length
            ? getListItem(suggestions[index], theme)
            : const SizedBox();
      },
      separatorBuilder: (BuildContext context, int index) {
        if (index >= suggestions.length - 1) {
          return const SizedBox();
        }
        return Divider(
          height: 1,
          thickness: 1,
          color: theme.palette.getAccent100(),
        );
      },
    ),
  );
}