showLoading method

void showLoading({
  1. String? key = LoadingKeys.global,
})

Shows the loading overlay for a specific key.

key is a unique identifier for the loading state. If not provided, it defaults to LoadingKeys.global.

This method adds a SetComponentLoading event to the commonBloc to activate the loading state.

Usage:

void someMethodThatNeedsLoading() {
  showLoading(key: LoadingKeys.global); // Or use a specific key
  try {
    // Do some work
  } finally {
    hideLoading(key: LoadingKeys.global); // Make sure to use the same key
  }
}

Implementation

void showLoading({String? key = LoadingKeys.global}) {
  commonBloc.add(SetComponentLoading(key: key!, isLoading: true));
}