appObjectX method

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

Implementation

Widget appObjectX(NotifierBuilder<T?> widget,
    {Widget Function()? onError,
    Widget Function()? onEmpty,
    Widget Function()? onLoading,
    Function? onRetry}) {
  return SimpleBuilder(builder: (_) {
    if (status.isLoading) {
      return onLoading != null ? onLoading() : const Text('Loading');
    } else if (status.isError) {
      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);
  });
}