group<T> function

Future<T?> group<T>({
  1. required String name,
  2. required Future<T> fn(),
})

Wraps an asynchronous function call in a group.

Returns the same type as the function itself.

Implementation

Future<T?> group<T>({
  required String name,
  required Future<T> Function() fn,
}) async {
  startGroup(name: name);

  T? result;

  try {
    result = await fn();
  } finally {
    endGroup();
  }

  return result;
}