track<T> method

T? track<T>(
  1. Element? element,
  2. ElementValueGetter<T>? elementValueGetter,
  3. OnElementTrackValueEvent<T>? onTrackValueEvent, {
  4. bool periodicTracking = false,
})

Tracks element using elementValueGetter to catch the value.

element The element to track. elementValueGetter The value getter. onTrackValueEvent Callback to call when value changes. periodicTracking If true this tracking will continue after first event.

Implementation

T? track<T>(Element? element, ElementValueGetter<T>? elementValueGetter,
    OnElementTrackValueEvent<T>? onTrackValueEvent,
    {bool periodicTracking = false}) {
  if (element == null ||
      elementValueGetter == null ||
      onTrackValueEvent == null) return null;

  if (_elements.containsKey(element)) return null;

  var elementTrack = _ElementTrack(
      this, element, elementValueGetter, periodicTracking, onTrackValueEvent);
  _elements[element] = elementTrack;

  var initialValue = elementTrack._initialize();

  _scheduleCheck();

  return initialValue;
}