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
58007fc6
Unverified
Commit
58007fc6
authored
Jun 17, 2022
by
Bruno Leroux
Committed by
GitHub
Jun 17, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix debugPaintSize throws 'Null Check error' (#106108)
parent
d08a1b02
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
93 additions
and
8 deletions
+93
-8
box.dart
packages/flutter/lib/src/rendering/box.dart
+1
-0
proxy_box.dart
packages/flutter/lib/src/rendering/proxy_box.dart
+16
-8
proxy_box_test.dart
packages/flutter/test/rendering/proxy_box_test.dart
+76
-0
No files found.
packages/flutter/lib/src/rendering/box.dart
View file @
58007fc6
...
@@ -2738,6 +2738,7 @@ abstract class RenderBox extends RenderObject {
...
@@ -2738,6 +2738,7 @@ abstract class RenderBox extends RenderObject {
///
///
/// Called for every [RenderBox] when [debugPaintSizeEnabled] is true.
/// Called for every [RenderBox] when [debugPaintSizeEnabled] is true.
@protected
@protected
@visibleForTesting
void
debugPaintSize
(
PaintingContext
context
,
Offset
offset
)
{
void
debugPaintSize
(
PaintingContext
context
,
Offset
offset
)
{
assert
(()
{
assert
(()
{
final
Paint
paint
=
Paint
()
final
Paint
paint
=
Paint
()
...
...
packages/flutter/lib/src/rendering/proxy_box.dart
View file @
58007fc6
...
@@ -1580,9 +1580,11 @@ class RenderClipRect extends _RenderCustomClip<Rect> {
...
@@ -1580,9 +1580,11 @@ class RenderClipRect extends _RenderCustomClip<Rect> {
assert
(()
{
assert
(()
{
if
(
child
!=
null
)
{
if
(
child
!=
null
)
{
super
.
debugPaintSize
(
context
,
offset
);
super
.
debugPaintSize
(
context
,
offset
);
if
(
clipBehavior
!=
Clip
.
none
)
{
context
.
canvas
.
drawRect
(
_clip
!.
shift
(
offset
),
_debugPaint
!);
context
.
canvas
.
drawRect
(
_clip
!.
shift
(
offset
),
_debugPaint
!);
_debugText
!.
paint
(
context
.
canvas
,
offset
+
Offset
(
_clip
!.
width
/
8.0
,
-
_debugText
!.
text
!.
style
!.
fontSize
!
*
1.1
));
_debugText
!.
paint
(
context
.
canvas
,
offset
+
Offset
(
_clip
!.
width
/
8.0
,
-
_debugText
!.
text
!.
style
!.
fontSize
!
*
1.1
));
}
}
}
return
true
;
return
true
;
}());
}());
}
}
...
@@ -1687,9 +1689,11 @@ class RenderClipRRect extends _RenderCustomClip<RRect> {
...
@@ -1687,9 +1689,11 @@ class RenderClipRRect extends _RenderCustomClip<RRect> {
assert
(()
{
assert
(()
{
if
(
child
!=
null
)
{
if
(
child
!=
null
)
{
super
.
debugPaintSize
(
context
,
offset
);
super
.
debugPaintSize
(
context
,
offset
);
if
(
clipBehavior
!=
Clip
.
none
)
{
context
.
canvas
.
drawRRect
(
_clip
!.
shift
(
offset
),
_debugPaint
!);
context
.
canvas
.
drawRRect
(
_clip
!.
shift
(
offset
),
_debugPaint
!);
_debugText
!.
paint
(
context
.
canvas
,
offset
+
Offset
(
_clip
!.
tlRadiusX
,
-
_debugText
!.
text
!.
style
!.
fontSize
!
*
1.1
));
_debugText
!.
paint
(
context
.
canvas
,
offset
+
Offset
(
_clip
!.
tlRadiusX
,
-
_debugText
!.
text
!.
style
!.
fontSize
!
*
1.1
));
}
}
}
return
true
;
return
true
;
}());
}());
}
}
...
@@ -1773,9 +1777,11 @@ class RenderClipOval extends _RenderCustomClip<Rect> {
...
@@ -1773,9 +1777,11 @@ class RenderClipOval extends _RenderCustomClip<Rect> {
assert
(()
{
assert
(()
{
if
(
child
!=
null
)
{
if
(
child
!=
null
)
{
super
.
debugPaintSize
(
context
,
offset
);
super
.
debugPaintSize
(
context
,
offset
);
if
(
clipBehavior
!=
Clip
.
none
)
{
context
.
canvas
.
drawPath
(
_getClipPath
(
_clip
!).
shift
(
offset
),
_debugPaint
!);
context
.
canvas
.
drawPath
(
_getClipPath
(
_clip
!).
shift
(
offset
),
_debugPaint
!);
_debugText
!.
paint
(
context
.
canvas
,
offset
+
Offset
((
_clip
!.
width
-
_debugText
!.
width
)
/
2.0
,
-
_debugText
!.
text
!.
style
!.
fontSize
!
*
1.1
));
_debugText
!.
paint
(
context
.
canvas
,
offset
+
Offset
((
_clip
!.
width
-
_debugText
!.
width
)
/
2.0
,
-
_debugText
!.
text
!.
style
!.
fontSize
!
*
1.1
));
}
}
}
return
true
;
return
true
;
}());
}());
}
}
...
@@ -1851,9 +1857,11 @@ class RenderClipPath extends _RenderCustomClip<Path> {
...
@@ -1851,9 +1857,11 @@ class RenderClipPath extends _RenderCustomClip<Path> {
assert
(()
{
assert
(()
{
if
(
child
!=
null
)
{
if
(
child
!=
null
)
{
super
.
debugPaintSize
(
context
,
offset
);
super
.
debugPaintSize
(
context
,
offset
);
if
(
clipBehavior
!=
Clip
.
none
)
{
context
.
canvas
.
drawPath
(
_clip
!.
shift
(
offset
),
_debugPaint
!);
context
.
canvas
.
drawPath
(
_clip
!.
shift
(
offset
),
_debugPaint
!);
_debugText
!.
paint
(
context
.
canvas
,
offset
);
_debugText
!.
paint
(
context
.
canvas
,
offset
);
}
}
}
return
true
;
return
true
;
}());
}());
}
}
...
...
packages/flutter/test/rendering/proxy_box_test.dart
View file @
58007fc6
...
@@ -9,6 +9,7 @@ import 'package:flutter/material.dart';
...
@@ -9,6 +9,7 @@ import 'package:flutter/material.dart';
import
'package:flutter/rendering.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'mock_canvas.dart'
;
import
'rendering_tester.dart'
;
import
'rendering_tester.dart'
;
void
main
(
)
{
void
main
(
)
{
...
@@ -770,6 +771,81 @@ void main() {
...
@@ -770,6 +771,81 @@ void main() {
Offset
.
zero
&
renderClipRect
.
size
,
Offset
.
zero
&
renderClipRect
.
size
,
);
);
});
});
// Simulate painting a RenderBox as if 'debugPaintSizeEnabled == true'
Function
(
PaintingContext
,
Offset
)
debugPaint
(
RenderBox
renderBox
)
{
layout
(
renderBox
);
pumpFrame
(
phase:
EnginePhase
.
compositingBits
);
return
(
PaintingContext
context
,
Offset
offset
)
{
renderBox
.
paint
(
context
,
offset
);
renderBox
.
debugPaintSize
(
context
,
offset
);
};
}
test
(
'RenderClipPath.debugPaintSize draws a path and a debug text when clipBehavior is not Clip.none'
,
()
{
Function
(
PaintingContext
,
Offset
)
debugPaintClipRect
(
Clip
clip
)
{
final
RenderBox
child
=
RenderConstrainedBox
(
additionalConstraints:
const
BoxConstraints
.
tightFor
(
width:
200
,
height:
200
));
final
RenderClipPath
renderClipPath
=
RenderClipPath
(
clipBehavior:
clip
,
child:
child
);
return
debugPaint
(
renderClipPath
);
}
// RenderClipPath.debugPaintSize draws when clipBehavior is not Clip.none
expect
(
debugPaintClipRect
(
Clip
.
hardEdge
),
paintsExactlyCountTimes
(
#drawPath
,
1
));
expect
(
debugPaintClipRect
(
Clip
.
hardEdge
),
paintsExactlyCountTimes
(
#drawParagraph
,
1
));
// RenderClipPath.debugPaintSize does not draw when clipBehavior is Clip.none
// Regression test for https://github.com/flutter/flutter/issues/105969
expect
(
debugPaintClipRect
(
Clip
.
none
),
paintsExactlyCountTimes
(
#drawPath
,
0
));
expect
(
debugPaintClipRect
(
Clip
.
none
),
paintsExactlyCountTimes
(
#drawParagraph
,
0
));
});
test
(
'RenderClipRect.debugPaintSize draws a rect and a debug text when clipBehavior is not Clip.none'
,
()
{
Function
(
PaintingContext
,
Offset
)
debugPaintClipRect
(
Clip
clip
)
{
final
RenderBox
child
=
RenderConstrainedBox
(
additionalConstraints:
const
BoxConstraints
.
tightFor
(
width:
200
,
height:
200
));
final
RenderClipRect
renderClipRect
=
RenderClipRect
(
clipBehavior:
clip
,
child:
child
);
return
debugPaint
(
renderClipRect
);
}
// RenderClipRect.debugPaintSize draws when clipBehavior is not Clip.none
expect
(
debugPaintClipRect
(
Clip
.
hardEdge
),
paintsExactlyCountTimes
(
#drawRect
,
1
));
expect
(
debugPaintClipRect
(
Clip
.
hardEdge
),
paintsExactlyCountTimes
(
#drawParagraph
,
1
));
// RenderClipRect.debugPaintSize does not draw when clipBehavior is Clip.none
expect
(
debugPaintClipRect
(
Clip
.
none
),
paintsExactlyCountTimes
(
#drawRect
,
0
));
expect
(
debugPaintClipRect
(
Clip
.
none
),
paintsExactlyCountTimes
(
#drawParagraph
,
0
));
});
test
(
'RenderClipRRect.debugPaintSize draws a rounded rect and a debug text when clipBehavior is not Clip.none'
,
()
{
Function
(
PaintingContext
,
Offset
)
debugPaintClipRRect
(
Clip
clip
)
{
final
RenderBox
child
=
RenderConstrainedBox
(
additionalConstraints:
const
BoxConstraints
.
tightFor
(
width:
200
,
height:
200
));
final
RenderClipRRect
renderClipRRect
=
RenderClipRRect
(
clipBehavior:
clip
,
child:
child
);
return
debugPaint
(
renderClipRRect
);
}
// RenderClipRRect.debugPaintSize draws when clipBehavior is not Clip.none
expect
(
debugPaintClipRRect
(
Clip
.
hardEdge
),
paintsExactlyCountTimes
(
#drawRRect
,
1
));
expect
(
debugPaintClipRRect
(
Clip
.
hardEdge
),
paintsExactlyCountTimes
(
#drawParagraph
,
1
));
// RenderClipRRect.debugPaintSize does not draw when clipBehavior is Clip.none
expect
(
debugPaintClipRRect
(
Clip
.
none
),
paintsExactlyCountTimes
(
#drawRRect
,
0
));
expect
(
debugPaintClipRRect
(
Clip
.
none
),
paintsExactlyCountTimes
(
#drawParagraph
,
0
));
});
test
(
'RenderClipOval.debugPaintSize draws a path and a debug text when clipBehavior is not Clip.none'
,
()
{
Function
(
PaintingContext
,
Offset
)
debugPaintClipOval
(
Clip
clip
)
{
final
RenderBox
child
=
RenderConstrainedBox
(
additionalConstraints:
const
BoxConstraints
.
tightFor
(
width:
200
,
height:
200
));
final
RenderClipOval
renderClipOval
=
RenderClipOval
(
clipBehavior:
clip
,
child:
child
);
return
debugPaint
(
renderClipOval
);
}
// RenderClipOval.debugPaintSize draws when clipBehavior is not Clip.none
expect
(
debugPaintClipOval
(
Clip
.
hardEdge
),
paintsExactlyCountTimes
(
#drawPath
,
1
));
expect
(
debugPaintClipOval
(
Clip
.
hardEdge
),
paintsExactlyCountTimes
(
#drawParagraph
,
1
));
// RenderClipOval.debugPaintSize does not draw when clipBehavior is Clip.none
expect
(
debugPaintClipOval
(
Clip
.
none
),
paintsExactlyCountTimes
(
#drawPath
,
0
));
expect
(
debugPaintClipOval
(
Clip
.
none
),
paintsExactlyCountTimes
(
#drawParagraph
,
0
));
});
}
}
class
_TestRectClipper
extends
CustomClipper
<
Rect
>
{
class
_TestRectClipper
extends
CustomClipper
<
Rect
>
{
...
...
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