attach method

  1. @override
void attach(
  1. covariant PipelineOwner owner
)
override

Mark this render object as attached to the given owner.

Typically called only from the parent's attach method, and by the owner to mark the root of a tree as attached.

Subclasses with children should override this method to attach all their children to the same owner after calling the inherited method, as in super.attach(owner).

Implementation

@override
void attach(covariant PipelineOwner owner) {
  super.attach(owner);
  parentData!.startDateTime = startDateTime;
  parentData!.endDateTime = endDateTime;
  parentData!.position = position;

  _microsecondExtent = parentData!.microsecondExtent;

  _minItemDuration = parentData!.minItemDuration;

  _minItemExtent = _minItemDuration.inMicroseconds * _microsecondExtent;

  _axis = parentData!.axis;

  _resizable = parentData!.resizable;

  assert(
    !_resizable || endDateTime.difference(startDateTime) >= _minItemDuration,
    'resizable widgets can not have a duration less than minItemDuration',
  );

  if (_resizable) {
    if (_axis == Axis.vertical) {
      _topDragGestureRecognizer = VerticalDragGestureRecognizer()
        ..onUpdate = _onUpdateTopOrLeft
        ..onEnd = _onEndTopOrLeft
        ..dragStartBehavior = DragStartBehavior.down;

      _bottomDragGestureRecognizer = VerticalDragGestureRecognizer()
        ..onUpdate = _onUpdateBottomOrRight
        ..onEnd = _onEndBottomOrLeft
        ..dragStartBehavior = DragStartBehavior.down;
    } else {
      _leftDragGestureRecognizer = HorizontalDragGestureRecognizer()
        ..onUpdate = _onUpdateTopOrLeft
        ..onEnd = _onEndTopOrLeft
        ..dragStartBehavior = DragStartBehavior.down;

      _rightDragGestureRecognizer = HorizontalDragGestureRecognizer()
        ..onUpdate = _onUpdateBottomOrRight
        ..onEnd = _onEndBottomOrLeft
        ..dragStartBehavior = DragStartBehavior.down;
    }
  }
}