easy method

Widget easy(
  1. NotifierBuilder<T?> widget, {
  2. Widget onError(
    1. String? error
    )?,
  3. Widget? onLoading,
  4. Widget? onEmpty,
  5. void onLoadTap()?,
})

Implementation

Widget easy(
  NotifierBuilder<T?> widget, {
  Widget Function(String? error)? onError,
  Widget? onLoading,
  Widget? onEmpty,
  void Function()? onLoadTap,
}) {
  return SimpleBuilder(builder: (_) {
    if (status.isLoading) {
      return onLoading ?? const Center(child: BaseLoadingView());
    } else if (status.isError) {
      return onError != null
          ? onError(status.errorMessage)
          : Center(
              child: BasePlaceholderView(
              title: "${status.errorMessage}",
              onTap: onLoadTap,
            ));
    } else if (status.isEmpty) {
      return onEmpty != null
          ? onEmpty
          : SizedBox.shrink(); // Also can be widget(null); but is risky
    }
    return widget(state);
  });
}