track method

  1. @override
Stream<Rectangle<num>> track(
  1. Element element, {
  2. bool aways = false,
})

Returns a stream of bounding client rectangles for element.

NOTE: The first event is not guaranteed to happen in the same VM turn. To obtain a first response without waiting, use measure.

The stream is automatically deduped, and an updated scheduled whenever the DOM may have re-flowed (see DomService.onLayoutChanged). This is an expensive operation and should be limited to active elements.

Throws StateError if element is not within the live DOM.

Implementation

@override
Stream<Rectangle> track(Element element, {bool aways = false}) {
  if (canSyncWrite(element) && !aways) {
    // It is not possible to measure something not in the live DOM.
    // throw new StateError('Element is not in the live DOM document.');
    return Stream<Rectangle>.fromIterable(const [Rectangle(0, 0, 0, 0)]);
  }
  return super.track(element);
}