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
ba5a04e8
Commit
ba5a04e8
authored
Apr 12, 2016
by
Hans Muller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ClampOverscrolls Inherited Widget (#3267)
* ClampOverscrolls Inherited Widget
parent
8849cd6b
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
10 deletions
+45
-10
list_demo.dart
examples/material_gallery/lib/demo/list_demo.dart
+0
-1
list.dart
packages/flutter/lib/src/material/list.dart
+0
-3
overscroll_indicator.dart
packages/flutter/lib/src/material/overscroll_indicator.dart
+4
-1
scroll_behavior.dart
packages/flutter/lib/src/widgets/scroll_behavior.dart
+1
-1
scrollable_list.dart
packages/flutter/lib/src/widgets/scrollable_list.dart
+40
-4
No files found.
examples/material_gallery/lib/demo/list_demo.dart
View file @
ba5a04e8
...
...
@@ -194,7 +194,6 @@ class ListDemoState extends State<ListDemo> {
child:
new
MaterialList
(
type:
_itemType
,
scrollablePadding:
new
EdgeInsets
.
all
(
_dense
?
4.0
:
8.0
),
clampOverscrolls:
true
,
children:
listItems
)
)
...
...
packages/flutter/lib/src/material/list.dart
View file @
ba5a04e8
...
...
@@ -24,7 +24,6 @@ class MaterialList extends StatefulWidget {
this
.
initialScrollOffset
,
this
.
onScroll
,
this
.
type
:
MaterialListType
.
twoLine
,
this
.
clampOverscrolls
:
false
,
this
.
children
,
this
.
scrollablePadding
:
EdgeInsets
.
zero
,
this
.
scrollableKey
...
...
@@ -33,7 +32,6 @@ class MaterialList extends StatefulWidget {
final
double
initialScrollOffset
;
final
ScrollListener
onScroll
;
final
MaterialListType
type
;
final
bool
clampOverscrolls
;
final
Iterable
<
Widget
>
children
;
final
EdgeInsets
scrollablePadding
;
final
Key
scrollableKey
;
...
...
@@ -49,7 +47,6 @@ class _MaterialListState extends State<MaterialList> {
key:
config
.
scrollableKey
,
initialScrollOffset:
config
.
initialScrollOffset
,
scrollDirection:
Axis
.
vertical
,
clampOverscrolls:
config
.
clampOverscrolls
,
onScroll:
config
.
onScroll
,
itemExtent:
kListItemExtent
[
config
.
type
],
padding:
const
EdgeInsets
.
symmetric
(
vertical:
8.0
)
+
config
.
scrollablePadding
,
...
...
packages/flutter/lib/src/material/overscroll_indicator.dart
View file @
ba5a04e8
...
...
@@ -202,7 +202,10 @@ class _OverscrollIndicatorState extends State<OverscrollIndicator> {
child:
child
);
},
child:
config
.
child
child:
new
ClampOverscrolls
(
child:
config
.
child
,
value:
true
)
)
);
}
...
...
packages/flutter/lib/src/widgets/scroll_behavior.dart
View file @
ba5a04e8
...
...
@@ -90,7 +90,7 @@ abstract class ExtentScrollBehavior extends ScrollBehavior<double, double> {
void
debugFillDescription
(
List
<
String
>
description
)
{
super
.
debugFillDescription
(
description
);
description
.
add
(
'content:
${contentExtent.toStringAsFixed(1)}
'
);
description
.
add
(
'container:
${cont
ent
Extent.toStringAsFixed(1)}
'
);
description
.
add
(
'container:
${cont
ainer
Extent.toStringAsFixed(1)}
'
);
description
.
add
(
'range:
${minScrollOffset?.toStringAsFixed(1)}
..
${maxScrollOffset?.toStringAsFixed(1)}
'
);
}
}
...
...
packages/flutter/lib/src/widgets/scrollable_list.dart
View file @
ba5a04e8
...
...
@@ -11,6 +11,40 @@ import 'virtual_viewport.dart';
import
'package:flutter/rendering.dart'
;
/// If true, the ClampOverscroll's [Scrollable] descendant will clamp its
/// viewport's scrollOffsets to the [ScrollBehavior]'s min and max values.
/// In this case the Scrollable's scrollOffset will still over and undershoot
/// the ScrollBehavior's limits, but the viewport itself will not.
class
ClampOverscrolls
extends
InheritedWidget
{
ClampOverscrolls
({
Key
key
,
this
.
value
,
Widget
child
})
:
super
(
key:
key
,
child:
child
)
{
assert
(
value
!=
null
);
assert
(
child
!=
null
);
}
/// True if the [Scrollable] descendant should clamp its viewport's scrollOffset
/// values when they are less than the [ScrollBehavior]'s minimum or greater than
/// its maximum.
final
bool
value
;
static
bool
of
(
BuildContext
context
)
{
final
ClampOverscrolls
result
=
context
.
inheritFromWidgetOfExactType
(
ClampOverscrolls
);
return
result
?.
value
??
false
;
}
@override
bool
updateShouldNotify
(
ClampOverscrolls
old
)
=>
value
!=
old
.
value
;
@override
void
debugFillDescription
(
List
<
String
>
description
)
{
super
.
debugFillDescription
(
description
);
description
.
add
(
'value:
$value
'
);
}
}
class
ScrollableList
extends
Scrollable
{
ScrollableList
({
Key
key
,
...
...
@@ -21,7 +55,6 @@ class ScrollableList extends Scrollable {
SnapOffsetCallback
snapOffsetCallback
,
this
.
itemExtent
,
this
.
itemsWrap
:
false
,
this
.
clampOverscrolls
:
false
,
this
.
padding
,
this
.
children
})
:
super
(
...
...
@@ -37,7 +70,6 @@ class ScrollableList extends Scrollable {
final
double
itemExtent
;
final
bool
itemsWrap
;
final
bool
clampOverscrolls
;
final
EdgeInsets
padding
;
final
Iterable
<
Widget
>
children
;
...
...
@@ -64,10 +96,11 @@ class _ScrollableListState extends ScrollableState<ScrollableList> {
@override
Widget
buildContent
(
BuildContext
context
)
{
final
double
listScrollOffset
=
config
.
clampOverscrolls
final
bool
clampOverscrolls
=
ClampOverscrolls
.
of
(
context
);
final
double
listScrollOffset
=
clampOverscrolls
?
scrollOffset
.
clamp
(
scrollBehavior
.
minScrollOffset
,
scrollBehavior
.
maxScrollOffset
)
:
scrollOffset
;
return
new
ListViewport
(
Widget
viewport
=
new
ListViewport
(
onExtentsChanged:
_handleExtentsChanged
,
scrollOffset:
listScrollOffset
,
mainAxis:
config
.
scrollDirection
,
...
...
@@ -77,6 +110,9 @@ class _ScrollableListState extends ScrollableState<ScrollableList> {
padding:
config
.
padding
,
children:
config
.
children
);
if
(
clampOverscrolls
)
viewport
=
new
ClampOverscrolls
(
value:
false
,
child:
viewport
);
return
viewport
;
}
}
...
...
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