defaultErrorWidget static method

Widget defaultErrorWidget(
  1. BuildContext context
)

Default UI for LoaderState.error.

Implementation

static Widget defaultErrorWidget(BuildContext context) {
  final controller = LoaderController.of(context)!;
  final themeData = DefaultLoaderThemeData.of(context);
  return Center(
    child: Wrap(
      alignment: WrapAlignment.center,
      crossAxisAlignment: WrapCrossAlignment.center,
      direction: themeData.errorLayoutDirection,
      children: [
        Text(
          themeData.errorMessageResolver.call(controller.error),
          textAlign: TextAlign.center,
        ),
        if (themeData.showRetryWhenError)
          SizedBox(
            height: themeData.errorSpacing,
            width: themeData.errorSpacing,
          ),
        if (themeData.showRetryWhenError)
          ElevatedButton(
            onPressed: () => controller.load(),
            child: Text(themeData.retryLabel),
          )
      ],
    ),
  );
}