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
619eccd2
Unverified
Commit
619eccd2
authored
Aug 28, 2020
by
gaowanqiu
Committed by
GitHub
Aug 28, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix negative usableCrossAxisExtent in release mode (#64441)
parent
c26c2363
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
2 deletions
+43
-2
AUTHORS
AUTHORS
+1
-0
sliver_grid.dart
packages/flutter/lib/src/rendering/sliver_grid.dart
+4
-2
slivers_test.dart
packages/flutter/test/widgets/slivers_test.dart
+38
-0
No files found.
AUTHORS
View file @
619eccd2
...
...
@@ -64,3 +64,4 @@ Brian Wang <xinlei966@gmail.com>
CaiJingLong <cjl_spy@163.com>
Alex Li <google@alexv525.com>
Ram Navan <hiramprasad@gmail.com>
meritozh <ah841814092@gmail.com>
packages/flutter/lib/src/rendering/sliver_grid.dart
View file @
619eccd2
...
...
@@ -326,7 +326,8 @@ class SliverGridDelegateWithFixedCrossAxisCount extends SliverGridDelegate {
@override
SliverGridLayout
getLayout
(
SliverConstraints
constraints
)
{
assert
(
_debugAssertIsValid
());
final
double
usableCrossAxisExtent
=
constraints
.
crossAxisExtent
-
crossAxisSpacing
*
(
crossAxisCount
-
1
);
final
double
usableCrossAxisExtent
=
math
.
max
(
0.0
,
constraints
.
crossAxisExtent
-
crossAxisSpacing
*
(
crossAxisCount
-
1
));
final
double
childCrossAxisExtent
=
usableCrossAxisExtent
/
crossAxisCount
;
final
double
childMainAxisExtent
=
childCrossAxisExtent
/
childAspectRatio
;
return
SliverGridRegularTileLayout
(
...
...
@@ -425,7 +426,8 @@ class SliverGridDelegateWithMaxCrossAxisExtent extends SliverGridDelegate {
SliverGridLayout
getLayout
(
SliverConstraints
constraints
)
{
assert
(
_debugAssertIsValid
(
constraints
.
crossAxisExtent
));
final
int
crossAxisCount
=
(
constraints
.
crossAxisExtent
/
(
maxCrossAxisExtent
+
crossAxisSpacing
)).
ceil
();
final
double
usableCrossAxisExtent
=
constraints
.
crossAxisExtent
-
crossAxisSpacing
*
(
crossAxisCount
-
1
);
final
double
usableCrossAxisExtent
=
math
.
max
(
0.0
,
constraints
.
crossAxisExtent
-
crossAxisSpacing
*
(
crossAxisCount
-
1
));
final
double
childCrossAxisExtent
=
usableCrossAxisExtent
/
crossAxisCount
;
final
double
childMainAxisExtent
=
childCrossAxisExtent
/
childAspectRatio
;
return
SliverGridRegularTileLayout
(
...
...
packages/flutter/test/widgets/slivers_test.dart
View file @
619eccd2
...
...
@@ -308,6 +308,44 @@ void main() {
},
);
testWidgets
(
'SliverGrid negative usableCrossAxisExtent'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Center
(
child:
SizedBox
(
width:
4
,
height:
4
,
child:
CustomScrollView
(
slivers:
<
Widget
>[
SliverGrid
(
gridDelegate:
const
SliverGridDelegateWithFixedCrossAxisCount
(
crossAxisCount:
2
,
crossAxisSpacing:
8
,
mainAxisSpacing:
8
,
),
delegate:
SliverChildListDelegate
(
<
Widget
>[
Container
(
child:
const
Center
(
child:
Text
(
'A'
))),
Container
(
child:
const
Center
(
child:
Text
(
'B'
))),
Container
(
child:
const
Center
(
child:
Text
(
'C'
))),
Container
(
child:
const
Center
(
child:
Text
(
'D'
))),
],
),
),
],
),
),
),
),
);
expect
(
tester
.
takeException
(),
isNull
);
},
);
testWidgets
(
'SliverList can handle inaccurate scroll offset due to changes in children list'
,
(
WidgetTester
tester
)
async
{
...
...
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