onDispose abstract method Null safety

void onDispose(
  1. void cb(

    Adds a listener to perform an operation right before the provider is destroyed.

    This includes:

    • when the provider will rebuild (such as when using watch or refresh).
    • when an autoDispose provider is no longer used
    • when the associated ProviderContainer/ProviderScope is disposed`.

    See also:


    void onDispose(void Function() cb);