disposeProps method

  1. @protected
void disposeProps([
  1. bool predicate({
    1. Object? key,
    2. Object? value,
    })?
])
inherited

The disposeProps method is used to clean up resources associated with the store's properties, by stopping, closing, ignoring and removing timers, streams, sinks, and futures that are saved as properties in the store.

In more detail: This method accepts an optional predicate function that takes a prop key and a value as an argument and returns a boolean.

  • If you don't provide a predicate function, all properties which are Timer, Future, or Stream related will be closed/cancelled/ignored as appropriate, and then removed from the props. Other properties will not be removed.

  • If the predicate function is provided and returns true for a given property, that property will be removed from the props and, if the property is also a Timer, Future, or Stream related, it will be closed/cancelled/ignored as appropriate.

  • If the predicate function is provided and returns false for a given property, that property will not be removed from the props, and it will not be closed/cancelled/ignored.

This method is particularly useful when the store is being shut down, right before or after you called the Store.shutdown method.

Example usage:

// Dispose of all Timers, Futures, Stream related etc.
disposeProps();

// Dispose only Timers.
disposeProps(({Object? key, Object? value}) => value is Timer);

Note: The provided mixins, like Throttle and Debounce also use some props that you can dispose by doing store.internalMixinProps.clear();

See also: disposeProp, to dispose a single property by its key.

Implementation

@protected
void disposeProps([bool Function({Object? key, Object? value})? predicate]) =>
    store.disposeProps(predicate);