buildParent method

  1. @protected
ScrollPhysics? buildParent(
  1. ScrollPhysics? ancestor
)

If parent is null then return ancestor, otherwise recursively build a ScrollPhysics that has ancestor as its parent.

This method is typically used to define applyTo methods like:

class MyScrollPhysics extends ScrollPhysics {
  const MyScrollPhysics({ super.parent });

  @override
  MyScrollPhysics applyTo(ScrollPhysics? ancestor) {
    return MyScrollPhysics(parent: buildParent(ancestor));
  }

  // ...
}

Implementation

@protected
ScrollPhysics? buildParent(ScrollPhysics? ancestor) => parent?.applyTo(ancestor) ?? ancestor;