use<T> static method

Future<T> use<T>(
  1. FutureOr<T> body(
    1. List<OssLicense> licenses
    )
)

Runs body with the decoded license list and releases the reference when it completes — even if body throws. Prefer this for one-shot access: you never hold, or forget to close, a handle. Returns whatever body returns; body may be sync or async.

Implementation

static Future<T> use<T>(
  FutureOr<T> Function(List<OssLicense> licenses) body,
) async {
  final handle = await acquire();
  try {
    return await body(handle.licenses);
  } finally {
    handle.close();
  }
}