rebuild method

void rebuild()

Rebuilds this element if it is currently dirty.

Implementation

void rebuild() {
  if (!_dirty) return;
  _isRebuilding = true;
  try {
    _dirty = false;
    // Ensure the element is removed from the dirty set once rebuilt.
    // Without this, the dirty queue grows unbounded and render time
    // increases with each frame.
    _owner?.didRebuild(this);
    try {
      updateChildren(build());
    } catch (error, stackTrace) {
      final details = stackTrace.toString().split('\n').take(6).join('\n');
      updateChildren([
        TUIErrorWidget(
          message: 'Build failed in ${widget.runtimeType}: $error',
          details: details,
        ),
      ]);
    }
  } finally {
    _isRebuilding = false;
  }
}