Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
01201b5f
Unverified
Commit
01201b5f
authored
Oct 29, 2020
by
Ian Hickson
Committed by
GitHub
Oct 29, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add documentation talking about ScrollPhysics.applyTo(null) (#67585)
parent
99016e3f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
10 deletions
+34
-10
scroll_physics.dart
packages/flutter/lib/src/widgets/scroll_physics.dart
+34
-10
No files found.
packages/flutter/lib/src/widgets/scroll_physics.dart
View file @
01201b5f
...
...
@@ -85,21 +85,28 @@ class ScrollPhysics {
@protected
ScrollPhysics
?
buildParent
(
ScrollPhysics
?
ancestor
)
=>
parent
?.
applyTo
(
ancestor
)
??
ancestor
;
/// If [parent] is null then return a [ScrollPhysics] with the same
/// [runtimeType] where the [parent] has been replaced with the [ancestor].
/// Combines this [ScrollPhysics] instance with the given physics.
///
///
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 uses this instance's physics when it has an
///
opinion, and defers to the given `ancestor` object's physics
///
when it does not
.
///
/// The returned object will combine some of the behaviors from this
/// [ScrollPhysics] instance and some of the behaviors from [ancestor].
/// If [parent] is null then this returns a [ScrollPhysics] with the
/// same [runtimeType], but 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.
///
/// Calling this method with a null argument will copy the current
/// object. This is inefficient.
///
/// {@tool snippet}
///
/// In the following example, the [applyTo] method is used to combine the
/// scroll physics of two [ScrollPhysics] objects
, t
he resulting [ScrollPhysics]
/// `x` has the same behavior as `y`
:
/// scroll physics of two [ScrollPhysics] objects
. T
he resulting [ScrollPhysics]
/// `x` has the same behavior as `y`
.
///
/// ```dart
/// final FooScrollPhysics x = FooScrollPhysics().applyTo(BarScrollPhysics());
...
...
@@ -107,10 +114,27 @@ class ScrollPhysics {
/// ```
/// {@end-tool}
///
/// ## Implementing `applyTo`
///
/// When creating a custom [ScrollPhysics] subclass, this method
/// must be implemented. If the physics class has no constructor
/// arguments, then implementing this method is merely a matter of
/// calling the constructor with a [parent] constructed using
/// [buildParent], as follows:
///
/// ```dart
/// FooScrollPhysics applyTo(ScrollPhysics ancestor) {
/// return FooScrollPhysics(parent: buildParent(ancestor));
/// }
/// ```
///
/// If the physics class has constructor arguments, they must be passed to
/// the constructor here as well, so as to create a clone.
///
/// See also:
///
/// * [buildParent], a utility method that's often used to define [applyTo]
/// methods for
ScrollPhysics
subclasses.
/// methods for
[ScrollPhysics]
subclasses.
ScrollPhysics
applyTo
(
ScrollPhysics
?
ancestor
)
{
return
ScrollPhysics
(
parent:
buildParent
(
ancestor
));
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment