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
75633c8c
Commit
75633c8c
authored
Aug 25, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #784 from abarth/rm_epsilon
Remove floating-point errors from ScrollableWidgetList
parents
465fbbf9
c696c21a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
18 deletions
+5
-18
scrollable.dart
packages/flutter/lib/widgets/scrollable.dart
+5
-18
No files found.
packages/flutter/lib/widgets/scrollable.dart
View file @
75633c8c
...
...
@@ -338,8 +338,6 @@ class Block extends Component {
/// widget when you have a large number of children or when you are concerned
// about offscreen widgets consuming resources.
abstract
class
ScrollableWidgetList
extends
Scrollable
{
static
const
_kEpsilon
=
.
0000001
;
ScrollableWidgetList
({
Key
key
,
ScrollDirection
scrollDirection:
ScrollDirection
.
vertical
,
...
...
@@ -445,24 +443,13 @@ abstract class ScrollableWidgetList extends Scrollable {
if
(
paddedScrollOffset
<
scrollBehavior
.
minScrollOffset
)
{
// Underscroll
double
visibleExtent
=
_containerExtent
+
paddedScrollOffset
;
itemShowCount
=
(
visibleExtent
/
itemExtent
).
round
()
+
1
;
itemShowCount
=
(
visibleExtent
/
itemExtent
).
ceil
()
;
viewportOffset
=
_toOffset
(
paddedScrollOffset
);
}
else
{
itemShowCount
=
(
_containerExtent
/
itemExtent
).
ceil
();
double
alignmentDelta
=
(-
paddedScrollOffset
%
itemExtent
);
double
drawStart
=
paddedScrollOffset
;
if
(
alignmentDelta
!=
0.0
)
{
alignmentDelta
-=
itemExtent
;
itemShowCount
+=
1
;
drawStart
+=
alignmentDelta
;
viewportOffset
=
_toOffset
(-
alignmentDelta
);
}
if
(
itemCount
>
0
)
{
// floor(epsilon) = 0, floor(-epsilon) = -1, so:
if
(
drawStart
.
abs
()
<
_kEpsilon
)
drawStart
=
0.0
;
itemShowIndex
=
(
drawStart
/
itemExtent
).
floor
()
%
itemCount
;
}
itemShowCount
=
(
_containerExtent
/
itemExtent
).
ceil
()
+
1
;
itemShowIndex
=
(
paddedScrollOffset
/
itemExtent
).
floor
();
viewportOffset
=
_toOffset
(
paddedScrollOffset
-
itemShowIndex
*
itemExtent
);
itemShowIndex
%=
itemCount
;
// Wrap index for when itemWrap is true.
}
}
...
...
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