collectionWrapperBuilder method

Widget collectionWrapperBuilder(
  1. BuildContext context,
  2. BlocxCollectionState<T> state
)

Wraps the main collection widget with optional top and bottom widgets.

Implementation

Widget collectionWrapperBuilder(
  BuildContext context,
  BlocxCollectionState<T> state,
) {
  final top = topWidget(context, state);
  final bottom = bottomWidget(context, state);
  final isLoadingOrSearching = isLoading || isSearching;
  final isEmpty = !isLoading && state.list.isEmpty;

  final coreBox = isLoadingOrSearching || isEmpty
      ? isLoadingOrSearching
          ? loadingWidget(context, state)
          : emptyWidget(context, state)
      : collectionWidget(context, state);

  final children = <Widget>[
    if (top != null) top,
    if (top != null) SizedBox(height: topBottomAndListSpacing),
    _collectionOptions.shrinkWrap ? coreBox : Expanded(child: coreBox),
    if (bottom != null) SizedBox(height: topBottomAndListSpacing),
    if (bottom != null) bottom,
  ];

  return Column(
    crossAxisAlignment: CrossAxisAlignment.stretch,
    children: children,
  );
}