renderStatePage method

Widget? renderStatePage(
  1. VxPageState? pageState
)

Render the corresponding page according to the state value

Implementation

Widget? renderStatePage(VxPageState? pageState) {
  switch (pageState) {
    /// Loading...
    case VxPageState.loading:
      if (widget.skeleton != null) {
        return widget.skeleton;
      }
      return Container(
        alignment: Alignment.center,
        child: _getIndicator(context),
      );

    /// empty page
    case VxPageState.empty:
      if (widget.emptyView != null) {
        return widget.emptyView;
      }
      return getStatePage(
        placeholder: ElevatedButton(
            onPressed: () {
              setState(() => _pageState = VxPageState.loading);
              widget.onRetry?.call();
            },
            child: const Text("Retry")),
        text: "Nothing to show",
      );

    /// error page
    case VxPageState.error:
      if (widget.errorView != null) {
        return widget.errorView;
      }
      return getStatePage(
        text: "Some error occured, please try again",
        placeholder: ElevatedButton(
            onPressed: () {
              setState(() => _pageState = VxPageState.loading);
              widget.onRetry?.call();
            },
            child: const Text("Retry")),
      );

    /// Normal content page
    default:
      return widget.child;
  }
}