content method

Widget content(
  1. BuildContext context, {
  2. required DeferredJobState<XWidget> state,
  3. required VoidCallback onRetry,
})

Implementation

Widget content(BuildContext context,
    {required DeferredJobState<XWidget> state,
    required VoidCallback onRetry}) {
  if (state.isInProgress || state.isReady) {
    return SliverToBoxAdapter(
      child: ShimmerContainer(
        height: params.placeholderHeight,
        width: params.placeholderWidth,
        color: Colors.grey[200]!,
        decoration: BoxDecoration(
          color: Colors.grey,
          borderRadius: BorderRadius.circular(10),
        ),
        margin: const EdgeInsets.symmetric(horizontal: 24, vertical: 8),
      ),
    );
  }

  if (state.isFailed) {
    return SliverToBoxAdapter(
      child: GestureDetector(
        onTap: onRetry,
        child: ShimmerContainer(
          alignment: Alignment.center,
          height: params.placeholderHeight,
          width: params.placeholderWidth,
          margin: const EdgeInsets.symmetric(horizontal: 24, vertical: 8),
          color: Colors.grey[200]!,
          decoration: BoxDecoration(
            color: Colors.grey,
            borderRadius: BorderRadius.circular(10),
          ),
          child: const Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              Icon(PhosphorIcons.arrowCounterClockwise, size: 34),
              HubbleText('Retry')
            ],
          ),
        ),
      ),
    );
  }

  final IWidgetBuilder builder = getObject();
  return builder.build(context, state.data!);
}