appListX method

Widget appListX(
  1. NotifierBuilder<List<T>> widget, {
  2. Widget onError()?,
  3. Widget onEmpty()?,
  4. Widget onLoading()?,
  5. void onRetry()?,
})

Implementation

Widget appListX(NotifierBuilder<List<T>> widget,
    {Widget Function()? onError,
    Widget Function()? onEmpty,
    Widget Function()? onLoading,
    void Function()? onRetry}) {
  return SimpleBuilder(builder: (_) {
    if (status.isLoading) {
      return onLoading != null ? onLoading() : Text('Loading');
    } else if (status.isError) {
      // if (status.errorType == ApiErrorType.forceNoResult) {
      //   return onForceEmpty != null
      //       ? onForceEmpty()
      //       : const Center(child: Text('No data found'));
      // }
      return onError != null ? onError() : const Center(child: Text('Error'));
    } else if (status.isEmpty) {
      return onEmpty != null
          ? onEmpty()
          : const Center(child: Text('No data found'));
    }
    return widget(value);
  });
}