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
1e7f3955
Unverified
Commit
1e7f3955
authored
Jan 26, 2021
by
xubaolin
Committed by
GitHub
Jan 26, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix a RenderBox.size access exception (#74402)
parent
b4f69eb7
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
1 deletion
+37
-1
box.dart
packages/flutter/lib/src/rendering/box.dart
+2
-1
object.dart
packages/flutter/lib/src/rendering/object.dart
+3
-0
layout_builder_test.dart
packages/flutter/test/widgets/layout_builder_test.dart
+32
-0
No files found.
packages/flutter/lib/src/rendering/box.dart
View file @
1e7f3955
...
...
@@ -1942,7 +1942,8 @@ abstract class RenderBox extends RenderObject {
final
Size
?
_size
=
this
.
_size
;
if
(
_size
is
_DebugSize
)
{
assert
(
_size
.
_owner
==
this
);
if
(
RenderObject
.
debugActiveLayout
!=
null
)
{
if
(
RenderObject
.
debugActiveLayout
!=
null
&&
!
RenderObject
.
debugActiveLayout
!.
debugDoingThisLayoutWithCallback
)
{
assert
(
debugDoingThisResize
||
debugDoingThisLayout
||
_computingThisDryLayout
||
(
RenderObject
.
debugActiveLayout
==
parent
&&
_size
.
_canBeUsedByParent
),
...
...
packages/flutter/lib/src/rendering/object.dart
View file @
1e7f3955
...
...
@@ -1445,6 +1445,9 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im
bool
_needsLayout
=
true
;
RenderObject
?
_relayoutBoundary
;
/// Whether [invokeLayoutCallback] for this render object is currently running.
bool
get
debugDoingThisLayoutWithCallback
=>
_doingThisLayoutWithCallback
;
bool
_doingThisLayoutWithCallback
=
false
;
/// The layout constraints most recently supplied by the parent.
...
...
packages/flutter/test/widgets/layout_builder_test.dart
View file @
1e7f3955
...
...
@@ -663,6 +663,38 @@ void main() {
expect
(
spy
.
performLayoutCount
,
3
);
expect
(
spy
.
performResizeCount
,
2
);
});
testWidgets
(
'LayoutBuilder descendant widget can access [RenderBox.size] when rebuilding during layout'
,
(
WidgetTester
tester
)
async
{
Size
?
childSize
;
int
buildCount
=
0
;
Future
<
void
>
pumpTestWidget
(
Size
size
)
async
{
await
tester
.
pumpWidget
(
// Center is used to give the SizedBox the power to determine constraints for LayoutBuilder
Center
(
child:
SizedBox
.
fromSize
(
size:
size
,
child:
LayoutBuilder
(
builder:
(
BuildContext
context
,
BoxConstraints
constraints
)
{
buildCount
++;
if
(
buildCount
>
1
)
{
final
_RenderLayoutSpy
spy
=
tester
.
renderObject
(
find
.
byType
(
_LayoutSpy
));
childSize
=
spy
.
size
;
}
return
ColoredBox
(
color:
const
Color
(
0xffffffff
),
child:
_LayoutSpy
(),
);
}),
),
),
);
}
await
pumpTestWidget
(
const
Size
(
10.0
,
10.0
));
expect
(
childSize
,
isNull
);
await
pumpTestWidget
(
const
Size
(
10.0
,
10.0
));
expect
(
childSize
,
const
Size
(
10.0
,
10.0
));
});
}
class
_LayoutSpy
extends
LeafRenderObjectWidget
{
...
...
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