applyTo method

ScrollPhysics applyTo (ScrollPhysics ancestor)

If parent is null then return a ScrollPhysics with the same runtimeType where the parent has been replaced with the ancestor.

If this scroll physics object already has a parent, then this method is applied recursively and ancestor will appear at the end of the existing chain of parents.

The returned object will combine some of the behaviors from this ScrollPhysics instance and some of the behaviors from ancestor.

In the following example, the applyTo method is used to combine the scroll physics of two ScrollPhysics objects, the resulting ScrollPhysics x has the same behavior as y:
final FooScrollPhysics x = FooScrollPhysics().applyTo(BarScrollPhysics());
const FooScrollPhysics y = FooScrollPhysics(parent: BarScrollPhysics());

See also:

  • buildParent, a utility method that's often used to define applyTo methods for ScrollPhysics subclasses.

Implementation

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