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
e0f3001f
Commit
e0f3001f
authored
Jul 21, 2017
by
Collin Jackson
Committed by
GitHub
Jul 21, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix physics with NestedScrollView (#11326)
* Fix physics with NestedScrollView * Review feedback
parent
1f08bda3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
2 deletions
+42
-2
nested_scroll_view.dart
packages/flutter/lib/src/widgets/nested_scroll_view.dart
+3
-1
nested_scroll_view_test.dart
packages/flutter/test/widgets/nested_scroll_view_test.dart
+39
-1
No files found.
packages/flutter/lib/src/widgets/nested_scroll_view.dart
View file @
e0f3001f
...
...
@@ -135,7 +135,9 @@ class _NestedScrollViewState extends State<NestedScrollView> {
return
new
CustomScrollView
(
scrollDirection:
widget
.
scrollDirection
,
reverse:
widget
.
reverse
,
physics:
new
ClampingScrollPhysics
(
parent:
widget
.
physics
),
physics:
widget
.
physics
!=
null
?
widget
.
physics
.
applyTo
(
const
ClampingScrollPhysics
())
:
const
ClampingScrollPhysics
(),
controller:
_coordinator
.
_outerController
,
slivers:
widget
.
_buildSlivers
(
context
,
_coordinator
.
_innerController
,
_coordinator
.
hasScrolledBody
),
);
...
...
packages/flutter/test/widgets/nested_scroll_view_test.dart
View file @
e0f3001f
...
...
@@ -6,7 +6,21 @@ import 'package:flutter/foundation.dart';
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
Widget
buildTest
(
{
ScrollController
controller
,
String
title:
'TTTTTTTT'
})
{
class
_CustomPhysics
extends
ClampingScrollPhysics
{
const
_CustomPhysics
({
ScrollPhysics
parent
})
:
super
(
parent:
parent
);
@override
_CustomPhysics
applyTo
(
ScrollPhysics
ancestor
)
{
return
new
_CustomPhysics
(
parent:
buildParent
(
ancestor
));
}
@override
Simulation
createBallisticSimulation
(
ScrollMetrics
position
,
double
dragVelocity
)
{
return
new
ScrollSpringSimulation
(
spring
,
1000.0
,
1000.0
,
1000.0
);
}
}
Widget
buildTest
(
{
ScrollController
controller
,
String
title:
'TTTTTTTT'
})
{
return
new
MediaQuery
(
data:
const
MediaQueryData
(),
child:
new
Scaffold
(
...
...
@@ -288,4 +302,28 @@ void main() {
expect
(
tester
.
renderObject
<
RenderBox
>(
find
.
byType
(
AppBar
)).
size
.
height
,
200.0
);
});
testWidgets
(
'NestedScrollViews with custom physics'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
new
MediaQuery
(
data:
const
MediaQueryData
(),
child:
new
NestedScrollView
(
physics:
const
_CustomPhysics
(),
headerSliverBuilder:
(
BuildContext
context
,
bool
innerBoxIsScrolled
)
{
return
<
Widget
>[
const
SliverAppBar
(
floating:
true
,
title:
const
Text
(
'AA'
),
),
];
},
body:
new
Container
(),
)));
expect
(
find
.
text
(
'AA'
),
findsOneWidget
);
await
tester
.
pump
(
const
Duration
(
milliseconds:
500
));
final
Offset
point1
=
tester
.
getCenter
(
find
.
text
(
'AA'
));
await
tester
.
dragFrom
(
point1
,
const
Offset
(
0.0
,
200.0
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
20
));
final
Offset
point2
=
tester
.
getCenter
(
find
.
text
(
'AA'
));
expect
(
point1
.
dy
,
greaterThan
(
point2
.
dy
));
});
}
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