dispose-providers
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() {}
}