wrap<T> method

Future<T> wrap<T>(
  1. CkAuthLoadingType type,
  2. Future<T> action()
)

Wraps an async operation with loading state management. Sets loading to true before the operation, and false after (regardless of success or failure).

Implementation

Future<T> wrap<T>(CkAuthLoadingType type, Future<T> Function() action) async {
  setLoading(type, true);
  try {
    return await action();
  } finally {
    setLoading(type, false);
  }
}