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
649f49d4
Commit
649f49d4
authored
Jan 17, 2019
by
Remi Rousselet
Committed by
Michael Goderbauer
Jan 17, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Swap scope with gesture (#21157)
parent
56039b4b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
15 deletions
+43
-15
scrollable.dart
packages/flutter/lib/src/widgets/scrollable.dart
+23
-15
scrollable_of_test.dart
packages/flutter/test/widgets/scrollable_of_test.dart
+20
-0
No files found.
packages/flutter/lib/src/widgets/scrollable.dart
View file @
649f49d4
...
@@ -524,8 +524,19 @@ class ScrollableState extends State<Scrollable> with TickerProviderStateMixin
...
@@ -524,8 +524,19 @@ class ScrollableState extends State<Scrollable> with TickerProviderStateMixin
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
assert
(
position
!=
null
);
assert
(
position
!=
null
);
// _ScrollableScope must be placed above the BuildContext returned by notificationContext
// so that we can get this ScrollableState by doing the following:
//
// ScrollNotification notification;
// Scrollable.of(notification.context)
//
// Since notificationContext is pointing to _gestureDetectorKey.context, _ScrollableScope
// must be placed above the widget using it: RawGestureDetector
Widget
result
=
_ScrollableScope
(
scrollable:
this
,
position:
position
,
// TODO(ianh): Having all these global keys is sad.
// TODO(ianh): Having all these global keys is sad.
Widget
result
=
RawGestureDetector
(
child:
RawGestureDetector
(
key:
_gestureDetectorKey
,
key:
_gestureDetectorKey
,
gestures:
_gestureRecognizers
,
gestures:
_gestureRecognizers
,
behavior:
HitTestBehavior
.
opaque
,
behavior:
HitTestBehavior
.
opaque
,
...
@@ -536,9 +547,6 @@ class ScrollableState extends State<Scrollable> with TickerProviderStateMixin
...
@@ -536,9 +547,6 @@ class ScrollableState extends State<Scrollable> with TickerProviderStateMixin
key:
_ignorePointerKey
,
key:
_ignorePointerKey
,
ignoring:
_shouldIgnorePointer
,
ignoring:
_shouldIgnorePointer
,
ignoringSemantics:
false
,
ignoringSemantics:
false
,
child:
_ScrollableScope
(
scrollable:
this
,
position:
position
,
child:
widget
.
viewportBuilder
(
context
,
position
),
child:
widget
.
viewportBuilder
(
context
,
position
),
),
),
),
),
...
...
packages/flutter/test/widgets/scrollable_of_test.dart
View file @
649f49d4
...
@@ -82,4 +82,24 @@ void main() {
...
@@ -82,4 +82,24 @@ void main() {
controller
.
jumpTo
(
400.0
);
controller
.
jumpTo
(
400.0
);
expect
(
logValue
,
'listener 400.0'
);
expect
(
logValue
,
'listener 400.0'
);
});
});
testWidgets
(
'Scrollable.of() is possible using ScrollNotification context'
,
(
WidgetTester
tester
)
async
{
ScrollNotification
notification
;
await
tester
.
pumpWidget
(
NotificationListener
<
ScrollNotification
>(
onNotification:
(
ScrollNotification
value
)
{
notification
=
value
;
return
false
;
},
child:
SingleChildScrollView
(
child:
const
SizedBox
(
height:
1200.0
)
)
));
await
tester
.
startGesture
(
const
Offset
(
100.0
,
100.0
));
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
final
StatefulElement
scrollableElement
=
find
.
byType
(
Scrollable
).
evaluate
().
first
;
expect
(
Scrollable
.
of
(
notification
.
context
),
equals
(
scrollableElement
.
state
));
});
}
}
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