buildParent method Null safety

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

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:

FooScrollPhysics applyTo(ScrollPhysics ancestor) {
  return FooScrollPhysics(parent: buildParent(ancestor));
}

Implementation

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