Skip to content
pubscout

using

1.0.5, released a year ago by d-markey.ovh

Automatic resource cleanup and finalization similar to C# using and Java try-with-resource.

WASM-ready
$ flutter pub add using
Source repository

What it does

Provides a Releasable mixin and extension methods to ensure deterministic resource cleanup and automatic finalization. Supports safe execution scopes via use(), useAsync(), and consume() extension methods.

AI-written summary of version 1.0.5, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need deterministic cleanup of resources similar to C# IDisposable.
  • You want to ensure resources are released in a finally block or via extension methods.

Skip it when

  • You rely completely on deterministic garbage collection without explicit handles.

Strengths

  • Offers familiar scoping patterns like use() and useAsync() for resource management.
  • Includes support for Dart's Finalizer for non-deterministic clean-up fallback.
  • Simple mixin-based API.

Weaknesses

  • Relies on manual calls to super.release() and autoRelease() to manage nested resources.
  • Finalizer based auto-release is non-deterministic and not guaranteed.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
1
class Resource with Releasable {
  @override
  void release() {
    super.release();
  }
}

void main() {
  final data = Resource().use((res) {
    // use `res`
  });
}

Alternatives

Packages that do the same job and could replace using.

  • big_decimal

    A bugless implementation of BigDecimal in Dart based on Java's BigDecimal.

Works with

Packages commonly used together with using: ones it builds on, ones built on it, and its own family.