baseState method

Widget baseState(
  1. NotifierBuilder<T?> widget, {
  2. Widget onEmptyWidget(
    1. String? errorMessage
    )?,
  3. String? placeholderImagePath,
  4. String? placeholderEmptyTitle,
  5. void onReloadTap()?,
})

Implementation

Widget baseState(
  NotifierBuilder<T?> widget, {
  Widget Function(String? errorMessage)? onEmptyWidget,
  String? placeholderImagePath,
  String? placeholderEmptyTitle,
  void Function()? onReloadTap,
}) {
  return SimpleBuilder(
    builder: (_) {
      if (status.isLoading ||
          status.isEmpty ||
          status.isError ||
          state.isEmptyOrNull) {
        return onEmptyWidget != null
            ? onEmptyWidget(status.isEmpty
                ? (placeholderEmptyTitle ?? kEmptyList)
                : status.errorMessage)
            : BasePlaceholderView(
                title: status.isLoading
                    ? null
                    : (status.isEmpty
                        ? (placeholderEmptyTitle ?? kEmptyList)
                        : status.errorMessage),
                image: placeholderImagePath,
                onTap: onReloadTap ??
                    () {
                      change(null, status: RxStatus.loading());
                      onRequestData();
                    },
              );
      }
      return widget(state);
    },
  );
}