buildLoadingOverlay abstract method
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 overlayloadingKey: 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,
});