buildLoadingOverlay abstract method

Widget buildLoadingOverlay({
  1. required Widget child,
  2. String? loadingKey = LoadingKey.global,
  3. Widget? loadingWidget,
})

Wraps a widget with a loading overlay that can be shown/hidden based on loading state.

Parameters:

  • child: The widget to wrap with the loading overlay
  • loadingKey: Optional key to manage multiple loading states (defaults to global)
  • loadingWidget: Optional custom loading indicator widget

The loading state is managed by CommonBloc and can be controlled using:

// Show loading
bloc.showLoading(key: 'customKey');

// Hide loading
bloc.hideLoading(key: 'customKey');

Example usage:

@override
Widget buildPage(BuildContext context) {
  return buildLoadingOverlay(
    child: Scaffold(
      body: YourContent(),
    ),
    loadingKey: 'customKey',
    loadingWidget: CustomLoadingIndicator(),
  );
}

Features:

  • Animated opacity transitions
  • Support for multiple loading states
  • Custom loading indicator support
  • Efficient rebuilds using buildWhen

Implementation

Widget buildLoadingOverlay({
  required Widget child,
  String? loadingKey = LoadingKey.global,
  Widget? loadingWidget,
});