Skip to main content

dispose-providers

added in: 1.4.0
Pro+

Warns when a provided class with a dispose method does not have this method called in the Provider's dispose callback.

info

This rule will trigger for any class that has dispose, close or cancel methods not called inside the dispose callback.

Example

❌ Bad:

// LINT: This 'Provider' is not disposed, which can lead to a memory leak.
Provider(
create: () => DisposableService(),
);

class DisposableService {
void dispose() {}
}

✅ Good:

Provider(
create: () => DisposableService(),
dispose: (value) => value.dispose();
);

class DisposableService {
void dispose() {}
}