noLeaks<T> function

T noLeaks<T>(
  1. T action(
    1. NDDisposableBag bag
    )
)

Implementation

T noLeaks<T>(T Function(NDDisposableBag bag) action) {
  final bag = NDDisposableBag();
  try {
    return action(bag);
  } finally {
    bag.dispose();
  }
}