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
c76decb8
Commit
c76decb8
authored
Aug 29, 2016
by
Hans Muller
Committed by
GitHub
Aug 29, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Scrollable scrollBehavior when ScrollConfiguration changes (#5647)
parent
e0f6c0db
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
81 additions
and
9 deletions
+81
-9
scrollable.dart
packages/flutter/lib/src/widgets/scrollable.dart
+7
-2
scroll_behavior_test.dart
packages/flutter/test/widget/scroll_behavior_test.dart
+74
-7
No files found.
packages/flutter/lib/src/widgets/scrollable.dart
View file @
c76decb8
...
...
@@ -264,6 +264,13 @@ class ScrollableState<T extends Scrollable> extends State<T> {
super
.
dispose
();
}
@override
void
dependenciesChanged
()
{
_scrollBehavior
=
createScrollBehavior
();
didUpdateScrollBehavior
(
scrollOffset
);
super
.
dependenciesChanged
();
}
/// The current scroll offset.
///
/// The scroll offset is applied to the child widget along the scroll
...
...
@@ -351,8 +358,6 @@ class ScrollableState<T extends Scrollable> extends State<T> {
/// or its createScrollBehavior callback is null, then return a new instance
/// of [OverscrollWhenScrollableBehavior].
ExtentScrollBehavior
createScrollBehavior
()
{
// TODO(hansmuller): this will not be called when the ScrollConfiguration changes.
// An override of dependenciesChanged() is probably needed.
return
ScrollConfiguration
.
of
(
context
)?.
createScrollBehavior
();
}
...
...
packages/flutter/test/widget/scroll_behavior_test.dart
View file @
c76decb8
...
...
@@ -2,17 +2,37 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:test/test.dart'
;
class
TestScrollConfigurationDelegate
extends
ScrollConfigurationDelegate
{
TestScrollConfigurationDelegate
(
this
.
flag
);
final
bool
flag
;
@override
TargetPlatform
get
platform
=>
defaultTargetPlatform
;
@override
ExtentScrollBehavior
createScrollBehavior
()
{
return
flag
?
new
BoundedBehavior
(
platform:
platform
)
:
new
UnboundedBehavior
(
platform:
platform
);
}
@override
bool
updateShouldNotify
(
TestScrollConfigurationDelegate
old
)
=>
flag
!=
old
.
flag
;
}
void
main
(
)
{
test
(
'BoundedBehavior min scroll offset'
,
()
{
BoundedBehavior
behavior
=
new
BoundedBehavior
(
contentExtent:
150.0
,
containerExtent:
75.0
,
minScrollOffset:
-
100.0
,
platform:
TargetPlatform
.
iOS
);
BoundedBehavior
behavior
=
new
BoundedBehavior
(
contentExtent:
150.0
,
containerExtent:
75.0
,
minScrollOffset:
-
100.0
,
platform:
TargetPlatform
.
iOS
);
expect
(
behavior
.
minScrollOffset
,
equals
(-
100.0
));
expect
(
behavior
.
maxScrollOffset
,
equals
(-
25.0
));
...
...
@@ -35,4 +55,51 @@ void main() {
expect
(
behavior
.
maxScrollOffset
,
equals
(
125.0
));
expect
(
scrollOffset
,
equals
(
50.0
));
});
testWidgets
(
'Inherited ScrollConfiguration changed'
,
(
WidgetTester
tester
)
async
{
final
GlobalKey
scrollableKey
=
new
GlobalKey
(
debugLabel:
'scrollable'
);
TestScrollConfigurationDelegate
delegate
;
ExtentScrollBehavior
behavior
;
await
tester
.
pumpWidget
(
new
ScrollConfiguration
(
delegate:
new
TestScrollConfigurationDelegate
(
true
),
child:
new
ScrollableViewport
(
scrollableKey:
scrollableKey
,
child:
new
Builder
(
builder:
(
BuildContext
context
)
{
delegate
=
ScrollConfiguration
.
of
(
context
);
behavior
=
Scrollable
.
of
(
context
).
scrollBehavior
;
return
new
Container
(
height:
1000.0
);
}
)
)
)
);
expect
(
delegate
,
isNotNull
);
expect
(
delegate
.
flag
,
isTrue
);
expect
(
behavior
,
new
isInstanceOf
<
BoundedBehavior
>());
// Same Scrollable, different ScrollConfiguration
await
tester
.
pumpWidget
(
new
ScrollConfiguration
(
delegate:
new
TestScrollConfigurationDelegate
(
false
),
child:
new
ScrollableViewport
(
scrollableKey:
scrollableKey
,
child:
new
Builder
(
builder:
(
BuildContext
context
)
{
delegate
=
ScrollConfiguration
.
of
(
context
);
behavior
=
Scrollable
.
of
(
context
).
scrollBehavior
;
return
new
Container
(
height:
1000.0
);
}
)
)
)
);
expect
(
delegate
,
isNotNull
);
expect
(
delegate
.
flag
,
isFalse
);
expect
(
behavior
,
new
isInstanceOf
<
UnboundedBehavior
>());
});
}
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