baseShimmerState method

Widget baseShimmerState(
  1. NotifierBuilder<T?> widget, {
  2. bool validNullable = true,
  3. Color? baseColor,
  4. Color? highlightColor,
  5. Widget onPlaceholderWidget()?,
  6. Widget? placeholderEmptyWidget,
  7. String? placeholderEmptyTitle,
  8. String? placeholderEmptyMessage,
  9. TextStyle? placeholderEmptyTitleStyle(
    1. TextStyle
    )?,
  10. TextStyle? placeholderEmptyMessageStyle(
    1. TextStyle
    )?,
  11. EdgeInsetsGeometry? placeholderPadding,
  12. void onReloadTap()?,
})

Implementation

Widget baseShimmerState(
  NotifierBuilder<T?> widget, {
  bool validNullable = true,
  Color? baseColor,
  Color? highlightColor,
  Widget Function()? onPlaceholderWidget,
  Widget? placeholderEmptyWidget,
  String? placeholderEmptyTitle,
  String? placeholderEmptyMessage,
  TextStyle? Function(TextStyle)? placeholderEmptyTitleStyle,
  TextStyle? Function(TextStyle)? placeholderEmptyMessageStyle,
  EdgeInsetsGeometry? placeholderPadding,
  void Function()? onReloadTap,
}) {
  return SimpleBuilder(
    builder: (_) {
      if (status.isLoading ||
          status.isEmpty ||
          status.isError ||
          (validNullable && state.isEmptyOrNull)) {
        if (status.isLoading) {
          return BaseShimmer(
            visible: status.isLoading,
            child: widget(state),
            baseColor: baseColor,
            highlightColor: highlightColor,
          );
        }
        final titleStyle = Get.isDarkMode
            ? setDarkPlaceholderTitleTextStyle
            : setLightPlaceholderTitleTextStyle;
        final messageStyle = Get.isDarkMode
            ? setDarkPlaceholderMessageTextStyle
            : setLightPlaceholderMessageTextStyle;
        return Padding(
          padding: placeholderPadding ?? EdgeInsets.zero,
          child: onPlaceholderWidget != null
              ? onPlaceholderWidget()
              : BasePlaceholderView(
                  title: getPlaceholderTitle(placeholderEmptyTitle),
                  message: getPlaceholderMessage(placeholderEmptyMessage),
                  image: placeholderEmptyWidget,
                  titleStyle: placeholderEmptyTitleStyle?.call(titleStyle),
                  messageStyle:
                      placeholderEmptyMessageStyle?.call(messageStyle),
                  onTap: onReloadTap ??
                      () {
                        change(null, status: RxStatus.loading());
                        onRequestData();
                      },
                ),
        );
      }
      return widget(state);
    },
  );
}