onDispose abstract method

void onDispose(
  1. Future<void> callback()
)

Registers an async cleanup callback to run during dispose.

Callbacks are executed in reverse order of registration.

container.onDispose(() async {
  await analytics.flush();
});

Implementation

void onDispose(Future<void> Function() callback);