hideLoading method
Hides 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 deactivate 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 hideLoading({String key = LoadingKeys.global}) {
commonBloc.add(SetComponentLoading(key: key, isLoading: false));
}