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
cb9152ca
Commit
cb9152ca
authored
Feb 05, 2016
by
Ian Hickson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1637 from Hixie/asserts
Improve exceptions and asserts for rendering lib.
parents
79828ef2
1a0484cc
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
207 additions
and
102 deletions
+207
-102
sector_layout.dart
examples/rendering/lib/sector_layout.dart
+5
-5
block.dart
packages/flutter/lib/src/rendering/block.dart
+3
-2
box.dart
packages/flutter/lib/src/rendering/box.dart
+123
-32
object.dart
packages/flutter/lib/src/rendering/object.dart
+58
-50
view.dart
packages/flutter/lib/src/rendering/view.dart
+1
-1
mixed_viewport.dart
packages/flutter/lib/src/widgets/mixed_viewport.dart
+8
-4
scrollable.dart
packages/flutter/lib/src/widgets/scrollable.dart
+2
-1
custom_multi_child_layout_test.dart
...s/flutter/test/widget/custom_multi_child_layout_test.dart
+3
-3
custom_one_child_layout_test.dart
...ges/flutter/test/widget/custom_one_child_layout_test.dart
+4
-4
No files found.
examples/rendering/lib/sector_layout.dart
View file @
cb9152ca
...
...
@@ -79,16 +79,16 @@ abstract class RenderSector extends RenderObject {
}
SectorConstraints
get
constraints
=>
super
.
constraints
;
bool
debug
DoesMeetConstraints
()
{
void
debugAssert
DoesMeetConstraints
()
{
assert
(
constraints
!=
null
);
assert
(
deltaRadius
!=
null
);
assert
(
deltaRadius
<
double
.
INFINITY
);
assert
(
deltaTheta
!=
null
);
assert
(
deltaTheta
<
double
.
INFINITY
);
return
constraints
.
minDeltaRadius
<=
deltaRadius
&&
deltaRadius
<=
math
.
max
(
constraints
.
minDeltaRadius
,
constraints
.
maxDeltaRadius
)
&&
constraints
.
minDeltaTheta
<=
deltaTheta
&&
deltaTheta
<=
math
.
max
(
constraints
.
minDeltaTheta
,
constraints
.
maxDeltaTheta
);
assert
(
constraints
.
minDeltaRadius
<=
deltaRadius
);
assert
(
deltaRadius
<=
math
.
max
(
constraints
.
minDeltaRadius
,
constraints
.
maxDeltaRadius
));
assert
(
constraints
.
minDeltaTheta
<=
deltaTheta
);
assert
(
deltaTheta
<=
math
.
max
(
constraints
.
minDeltaTheta
,
constraints
.
maxDeltaTheta
)
);
}
void
performResize
()
{
// default behaviour for subclasses that have sizedByParent = true
...
...
packages/flutter/lib/src/rendering/block.dart
View file @
cb9152ca
...
...
@@ -350,8 +350,9 @@ class RenderBlockViewport extends RenderBlockBase {
double
result
;
if
(
intrinsicCallback
==
null
)
{
assert
(()
{
'RenderBlockViewport does not support returning intrinsic dimensions if the relevant callbacks have not been specified.'
;
return
RenderObject
.
debugInDebugDoesMeetConstraints
;
if
(!
RenderObject
.
debugCheckingIntrinsics
)
throw
new
UnsupportedError
(
'
$runtimeType
does not support returning intrinsic dimensions if the relevant callbacks have not been specified.'
);
return
true
;
});
return
constrainer
(
0.0
);
}
...
...
packages/flutter/lib/src/rendering/box.dart
View file @
cb9152ca
...
...
@@ -98,7 +98,7 @@ class BoxConstraints extends Constraints {
/// Returns new box constraints that are smaller by the given edge dimensions.
BoxConstraints
deflate
(
EdgeDims
edges
)
{
assert
(
edges
!=
null
);
assert
(
i
sNormalized
);
assert
(
debugAssertI
sNormalized
);
double
horizontal
=
edges
.
left
+
edges
.
right
;
double
vertical
=
edges
.
top
+
edges
.
bottom
;
double
deflatedMinWidth
=
math
.
max
(
0.0
,
minWidth
-
horizontal
);
...
...
@@ -113,7 +113,7 @@ class BoxConstraints extends Constraints {
/// Returns new box constraints that remove the minimum width and height requirements.
BoxConstraints
loosen
()
{
assert
(
i
sNormalized
);
assert
(
debugAssertI
sNormalized
);
return
new
BoxConstraints
(
minWidth:
0.0
,
maxWidth:
maxWidth
,
...
...
@@ -154,14 +154,14 @@ class BoxConstraints extends Constraints {
/// Returns the width that both satisfies the constraints and is as close as
/// possible to the given width.
double
constrainWidth
([
double
width
=
double
.
INFINITY
])
{
assert
(
i
sNormalized
);
assert
(
debugAssertI
sNormalized
);
return
width
.
clamp
(
minWidth
,
maxWidth
);
}
/// Returns the height that both satisfies the constraints and is as close as
/// possible to the given height.
double
constrainHeight
([
double
height
=
double
.
INFINITY
])
{
assert
(
i
sNormalized
);
assert
(
debugAssertI
sNormalized
);
return
height
.
clamp
(
minHeight
,
maxHeight
);
}
...
...
@@ -192,9 +192,15 @@ class BoxConstraints extends Constraints {
/// Whether there is exactly one size that satifies the constraints.
bool
get
isTight
=>
hasTightWidth
&&
hasTightHeight
;
/// Whether there is an upper bound on the maximum width.
bool
get
hasBoundedWidth
=>
maxWidth
<
double
.
INFINITY
;
/// Whether there is an upper bound on the maximum height.
bool
get
hasBoundedHeight
=>
maxHeight
<
double
.
INFINITY
;
/// Whether the given size satisfies the constraints.
bool
isSatisfiedBy
(
Size
size
)
{
assert
(
i
sNormalized
);
assert
(
debugAssertI
sNormalized
);
return
(
minWidth
<=
size
.
width
)
&&
(
size
.
width
<=
maxWidth
)
&&
(
minHeight
<=
size
.
height
)
&&
(
size
.
height
<=
maxHeight
);
}
...
...
@@ -245,8 +251,8 @@ class BoxConstraints extends Constraints {
return
b
*
t
;
if
(
b
==
null
)
return
a
*
(
1.0
-
t
);
assert
(
a
.
i
sNormalized
);
assert
(
b
.
i
sNormalized
);
assert
(
a
.
debugAssertI
sNormalized
);
assert
(
b
.
debugAssertI
sNormalized
);
return
new
BoxConstraints
(
minWidth:
ui
.
lerpDouble
(
a
.
minWidth
,
b
.
minWidth
,
t
),
maxWidth:
ui
.
lerpDouble
(
a
.
maxWidth
,
b
.
maxWidth
,
t
),
...
...
@@ -255,8 +261,34 @@ class BoxConstraints extends Constraints {
);
}
/// Returns whether the object's constraints are normalized.
/// Constraints are normalised if the minimums are less than or
/// equal to the corresponding maximums.
///
/// For example, a BoxConstraints object with a minWidth of 100.0
/// and a maxWidth of 90.0 is not normalized.
///
/// Most of the APIs on BoxConstraints expect the constraints to be
/// normalized and have undefined behavior when they are not. In
/// checked mode, many of these APIs will assert if the constraints
/// are not normalized.
bool
get
isNormalized
=>
minWidth
<=
maxWidth
&&
minHeight
<=
maxHeight
;
/// Same as [isNormalized] but, in checked mode, throws an exception
/// if isNormalized is false.
bool
get
debugAssertIsNormalized
{
assert
(()
{
if
(
maxWidth
<
minWidth
&&
maxHeight
<
minHeight
)
throw
new
RenderingError
(
'BoxConstraints has both width and height constraints non-normalized.
\n
$this
'
);
if
(
maxWidth
<
minWidth
)
throw
new
RenderingError
(
'BoxConstraints has non-normalized width constraints.
\n
$this
'
);
if
(
maxHeight
<
minHeight
)
throw
new
RenderingError
(
'BoxConstraints has non-normalized height constraints.
\n
$this
'
);
return
isNormalized
;
});
return
isNormalized
;
}
BoxConstraints
normalize
()
{
return
new
BoxConstraints
(
minWidth:
minWidth
,
...
...
@@ -267,13 +299,13 @@ class BoxConstraints extends Constraints {
}
bool
operator
==(
dynamic
other
)
{
assert
(
i
sNormalized
);
assert
(
debugAssertI
sNormalized
);
if
(
identical
(
this
,
other
))
return
true
;
if
(
other
is
!
BoxConstraints
)
return
false
;
final
BoxConstraints
typedOther
=
other
;
assert
(
typedOther
.
i
sNormalized
);
assert
(
typedOther
.
debugAssertI
sNormalized
);
return
minWidth
==
typedOther
.
minWidth
&&
maxWidth
==
typedOther
.
maxWidth
&&
minHeight
==
typedOther
.
minHeight
&&
...
...
@@ -281,7 +313,7 @@ class BoxConstraints extends Constraints {
}
int
get
hashCode
{
assert
(
i
sNormalized
);
assert
(
debugAssertI
sNormalized
);
return
hashValues
(
minWidth
,
maxWidth
,
minHeight
,
maxHeight
);
}
...
...
@@ -362,7 +394,7 @@ abstract class RenderBox extends RenderObject {
///
/// Override in subclasses that implement [performLayout].
double
getMinIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
i
sNormalized
);
assert
(
constraints
.
debugAssertI
sNormalized
);
return
constraints
.
constrainWidth
(
0.0
);
}
...
...
@@ -371,7 +403,7 @@ abstract class RenderBox extends RenderObject {
///
/// Override in subclasses that implement [performLayout].
double
getMaxIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
i
sNormalized
);
assert
(
constraints
.
debugAssertI
sNormalized
);
return
constraints
.
constrainWidth
(
0.0
);
}
...
...
@@ -380,7 +412,7 @@ abstract class RenderBox extends RenderObject {
///
/// Override in subclasses that implement [performLayout].
double
getMinIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
i
sNormalized
);
assert
(
constraints
.
debugAssertI
sNormalized
);
return
constraints
.
constrainHeight
(
0.0
);
}
...
...
@@ -393,7 +425,7 @@ abstract class RenderBox extends RenderObject {
///
/// Override in subclasses that implement [performLayout].
double
getMaxIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
i
sNormalized
);
assert
(
constraints
.
debugAssertI
sNormalized
);
return
constraints
.
constrainHeight
(
0.0
);
}
...
...
@@ -447,7 +479,7 @@ abstract class RenderBox extends RenderObject {
_size
=
new
_DebugSize
(
_size
,
this
,
debugCanParentUseSize
);
return
true
;
});
assert
(
debugDoesMeetConstraints
()
);
assert
(
()
{
debugAssertDoesMeetConstraints
();
return
true
;
}
);
}
Rect
get
semanticBounds
=>
Point
.
origin
&
size
;
...
...
@@ -532,32 +564,91 @@ abstract class RenderBox extends RenderObject {
/// The box constraints most recently received from the parent.
BoxConstraints
get
constraints
=>
super
.
constraints
;
bool
debugDoesMeetConstraints
()
{
assert
(!
RenderObject
.
debugInDebugDoesMeetConstraints
);
RenderObject
.
debugInDebugDoesMeetConstraints
=
true
;
void
debugAssertDoesMeetConstraints
()
{
assert
(
constraints
!=
null
);
// verify that the size is not infinite
assert
(
_size
!=
null
);
assert
(()
{
'See https://flutter.io/layout/#unbounded-constraints'
;
return
!
_size
.
isInfinite
;
});
// verify that the size is not infinite
if
(
_size
.
isInfinite
)
{
StringBuffer
information
=
new
StringBuffer
();
if
(!
constraints
.
hasBoundedWidth
)
{
RenderBox
node
=
this
;
while
(!
node
.
constraints
.
hasBoundedWidth
&&
node
.
parent
is
RenderBox
)
node
=
node
.
parent
;
information
.
writeln
(
'The nearest ancestor providing an unbounded width constraint is:'
);
information
.
writeln
(
'
$node
'
);
List
<
String
>
settings
=
<
String
>[];
node
.
debugDescribeSettings
(
settings
);
for
(
String
line
in
settings
)
information
.
writeln
(
'
$line
'
);
}
if
(!
constraints
.
hasBoundedHeight
)
{
RenderBox
node
=
this
;
while
(!
node
.
constraints
.
hasBoundedHeight
&&
node
.
parent
is
RenderBox
)
node
=
node
.
parent
;
information
.
writeln
(
'The nearest ancestor providing an unbounded height constraint is:'
);
information
.
writeln
(
'
$node
'
);
List
<
String
>
settings
=
<
String
>[];
node
.
debugDescribeSettings
(
settings
);
for
(
String
line
in
settings
)
information
.
writeln
(
'
$line
'
);
}
throw
new
RenderingError
(
'
$runtimeType
object was given an infinite size during layout.
\n
'
'This probably means that it is a render object that tries to be
\n
'
'as big as possible, but it was put inside another render object
\n
'
'that allows its children to pick their own size.
\n
'
'
$information
'
'See https://flutter.io/layout/ for more information.'
);
}
// verify that the size is within the constraints
bool
result
=
constraints
.
isSatisfiedBy
(
_size
);
if
(!
result
)
debugPrint
(
"
${this.runtimeType}
does not meet its constraints. Constraints:
$constraints
, size:
$_size
"
);
if
(!
constraints
.
isSatisfiedBy
(
_size
))
{
throw
new
RenderingError
(
'
$runtimeType
does not meet its constraints.
\n
'
'Constraints:
$constraints
\n
'
'Size:
$_size
\n
'
'If you are not writing your own RenderBox subclass, then this is not
\n
'
'your fault. Contact support: https://github.com/flutter/flutter/issues/new'
);
}
// verify that the intrinsics are also within the constraints
assert
(!
RenderObject
.
debugCheckingIntrinsics
);
RenderObject
.
debugCheckingIntrinsics
=
true
;
double
intrinsic
;
StringBuffer
failures
=
new
StringBuffer
();
int
failureCount
=
0
;
intrinsic
=
getMinIntrinsicWidth
(
constraints
);
assert
(
intrinsic
==
constraints
.
constrainWidth
(
intrinsic
));
if
(
intrinsic
!=
constraints
.
constrainWidth
(
intrinsic
))
{
failures
.
writeln
(
' * getMinIntrinsicWidth() -- returned: w=
$intrinsic
'
);
failureCount
+=
1
;
}
intrinsic
=
getMaxIntrinsicWidth
(
constraints
);
assert
(
intrinsic
==
constraints
.
constrainWidth
(
intrinsic
));
if
(
intrinsic
!=
constraints
.
constrainWidth
(
intrinsic
))
{
failures
.
writeln
(
' * getMaxIntrinsicWidth() -- returned: w=
$intrinsic
'
);
failureCount
+=
1
;
}
intrinsic
=
getMinIntrinsicHeight
(
constraints
);
assert
(
intrinsic
==
constraints
.
constrainHeight
(
intrinsic
));
if
(
intrinsic
!=
constraints
.
constrainHeight
(
intrinsic
))
{
failures
.
writeln
(
' * getMinIntrinsicHeight() -- returned: h=
$intrinsic
'
);
failureCount
+=
1
;
}
intrinsic
=
getMaxIntrinsicHeight
(
constraints
);
assert
(
intrinsic
==
constraints
.
constrainHeight
(
intrinsic
));
RenderObject
.
debugInDebugDoesMeetConstraints
=
false
;
return
result
;
if
(
intrinsic
!=
constraints
.
constrainHeight
(
intrinsic
))
{
failures
.
writeln
(
' * getMaxIntrinsicHeight() -- returned: h=
$intrinsic
'
);
failureCount
+=
1
;
}
RenderObject
.
debugCheckingIntrinsics
=
false
;
if
(
failures
.
isNotEmpty
)
{
assert
(
failureCount
>
0
);
throw
new
RenderingError
(
'The intrinsic dimension methods of the
$runtimeType
class returned values that violate the given constraints.
\n
'
'The constraints were:
$constraints
\n
'
'The following method
${failureCount > 1 ? "s" : ""}
returned values outside of those constraints:
\n
'
'
$failures
'
'If you are not writing your own RenderBox subclass, then this is not
\n
'
'your fault. Contact support: https://github.com/flutter/flutter/issues/new'
);
}
}
void
markNeedsLayout
()
{
...
...
packages/flutter/lib/src/rendering/object.dart
View file @
cb9152ca
...
...
@@ -724,52 +724,45 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
void
visitChildren
(
RenderObjectVisitor
visitor
)
{
}
dynamic
debugOwner
;
static
int
_debugPrintedExceptionCount
=
0
;
void
_debugReportException
(
String
method
,
dynamic
exception
,
StackTrace
stack
)
{
try
{
if
(
debugRenderingExceptionHandler
!=
null
)
{
debugRenderingExceptionHandler
(
this
,
method
,
exception
,
stack
);
}
else
{
debugPrint
(
'-- EXCEPTION CAUGHT BY RENDERING LIBRARY -------------------------------'
);
debugPrint
(
'The following exception was raised during
$method
():'
);
debugPrint
(
'
$exception
'
);
debugPrint
(
'The following RenderObject was being processed when the exception was fired:
\n
${this}
'
);
if
(
debugOwner
!=
null
)
debugPrint
(
'This RenderObject had the following owner:
\n
$debugOwner
'
);
int
depth
=
0
;
List
<
String
>
descendants
=
<
String
>[];
const
int
maxDepth
=
5
;
void
visitor
(
RenderObject
child
)
{
descendants
.
add
(
'
${" " * depth}$child
'
);
depth
+=
1
;
if
(
depth
<
maxDepth
)
child
.
visitChildren
(
visitor
);
depth
-=
1
;
}
visitChildren
(
visitor
);
if
(
descendants
.
length
>
1
)
{
debugPrint
(
'This RenderObject had the following descendants (showing up to depth
$maxDepth
):'
);
}
else
if
(
descendants
.
length
==
1
)
{
debugPrint
(
'This RenderObject had the following child:'
);
_debugPrintedExceptionCount
+=
1
;
if
(
_debugPrintedExceptionCount
==
1
)
{
debugPrint
(
'-- EXCEPTION CAUGHT BY RENDERING LIBRARY -------------------------------'
);
debugPrint
(
'The following exception was raised during
$method
():'
);
debugPrint
(
'
$exception
'
);
debugPrint
(
'The following RenderObject was being processed when the exception was fired:
\n
${this}
'
);
if
(
debugOwner
!=
null
)
debugPrint
(
'This RenderObject had the following owner:
\n
$debugOwner
'
);
int
depth
=
0
;
List
<
String
>
descendants
=
<
String
>[];
const
int
maxDepth
=
5
;
void
visitor
(
RenderObject
child
)
{
descendants
.
add
(
'
${" " * depth}$child
'
);
depth
+=
1
;
if
(
depth
<
maxDepth
)
child
.
visitChildren
(
visitor
);
depth
-=
1
;
}
visitChildren
(
visitor
);
if
(
descendants
.
length
>
1
)
{
debugPrint
(
'This RenderObject had the following descendants (showing up to depth
$maxDepth
):'
);
}
else
if
(
descendants
.
length
==
1
)
{
debugPrint
(
'This RenderObject had the following child:'
);
}
else
{
debugPrint
(
'This RenderObject has no descendants.'
);
}
descendants
.
forEach
(
debugPrint
);
debugPrint
(
'Stack trace:'
);
debugPrint
(
'
$stack
'
);
debugPrint
(
'------------------------------------------------------------------------'
);
}
else
{
debugPrint
(
'
This RenderObject has no descendants.
'
);
debugPrint
(
'
Another exception was raised:
${exception.toString().split("\n")[0]}
'
);
}
descendants
.
forEach
(
debugPrint
);
assert
(()
{
if
(
debugInDebugDoesMeetConstraints
)
{
debugPrint
(
'This exception was thrown while debugDoesMeetConstraints() was running.'
);
debugPrint
(
'debugDoesMeetConstraints() verifies that some invariants are not being'
);
debugPrint
(
'violated. For example, it verifies that RenderBox objects are sized in'
);
debugPrint
(
'a manner consistent with the constraints provided, and, in addition, that'
);
debugPrint
(
'the getMinIntrinsicWidth(), getMaxIntrinsicWidth(), etc, functions all'
);
debugPrint
(
'return consistent values within the same constraints.'
);
debugPrint
(
'If you are not writing your own RenderObject subclass, then this is not'
);
debugPrint
(
'your fault. Contact support: https://github.com/flutter/flutter/issues/new'
);
}
return
true
;
});
debugPrint
(
'Stack trace:'
);
debugPrint
(
'
$stack
'
);
debugPrint
(
'------------------------------------------------------------------------'
);
}
}
catch
(
exception
)
{
debugPrint
(
'(exception during exception handler:
$exception
)'
);
...
...
@@ -809,15 +802,23 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
Constraints
_constraints
;
/// The layout constraints most recently supplied by the parent.
Constraints
get
constraints
=>
_constraints
;
/// Override this function in a subclass to verify that your state matches the constraints object.
bool
debugDoesMeetConstraints
();
/// When true, debugDoesMeetConstraints() is currently executing.
///
/// This should be set by implementations of debugDoesMeetConstraints() so that
/// tests can selectively ignore custom layout callbacks. It should not be set
/// outside of debugDoesMeetConstraints() implementations and should not be used
/// for purposes other than tests.
static
bool
debugInDebugDoesMeetConstraints
=
false
;
/// Verify that the object's constraints are being met. Override
/// this function in a subclass to verify that your state matches
/// the constraints object. This function is only called in checked
/// mode. If the constraints are not met, it should assert or throw
/// an exception.
void
debugAssertDoesMeetConstraints
();
/// When true, debugAssertDoesMeetConstraints() is currently
/// executing asserts for verifying the consistent behaviour of
/// intrinsic dimensions methods.
///
/// This should only be set by debugAssertDoesMeetConstraints()
/// implementations. It is used by tests to selectively ignore
/// custom layout callbacks. It should not be set outside of
/// debugAssertDoesMeetConstraints(), and should not be checked in
/// release mode (where it will always be false).
static
bool
debugCheckingIntrinsics
=
false
;
bool
debugAncestorsAlreadyMarkedNeedsLayout
()
{
if
(
_relayoutSubtreeRoot
==
null
)
return
true
;
// we haven't yet done layout even once, so there's nothing for us to do
...
...
@@ -1022,7 +1023,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
assert
(()
{
_debugDoingThisResize
=
true
;
return
true
;
});
try
{
performResize
();
assert
(
debugDoesMeetConstraints
()
);
assert
(
()
{
debugAssertDoesMeetConstraints
();
return
true
;
}
);
}
catch
(
e
,
stack
)
{
_debugReportException
(
'performResize'
,
e
,
stack
);
}
...
...
@@ -1038,7 +1039,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
try
{
performLayout
();
markNeedsSemanticsUpdate
();
assert
(
debugDoesMeetConstraints
()
);
assert
(
()
{
debugAssertDoesMeetConstraints
();
return
true
;
}
);
}
catch
(
e
,
stack
)
{
_debugReportException
(
'performLayout'
,
e
,
stack
);
}
...
...
@@ -2023,3 +2024,10 @@ abstract class ContainerRenderObjectMixin<ChildType extends RenderObject, Parent
return
result
;
}
}
/// Error thrown when the rendering library encounters a contract violation.
class
RenderingError
extends
AssertionError
{
RenderingError
(
this
.
message
);
final
String
message
;
String
toString
()
=>
message
;
}
packages/flutter/lib/src/rendering/view.dart
View file @
cb9152ca
...
...
@@ -78,7 +78,7 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
// We never call layout() on this class, so this should never get
// checked. (This class is laid out using scheduleInitialLayout().)
bool
debugDoesMeetConstraints
()
{
assert
(
false
);
return
false
;
}
void
debugAssertDoesMeetConstraints
()
{
assert
(
false
)
;
}
void
performResize
()
{
assert
(
false
);
...
...
packages/flutter/lib/src/widgets/mixed_viewport.dart
View file @
cb9152ca
...
...
@@ -155,10 +155,14 @@ class _MixedViewportElement extends RenderObjectElement<MixedViewport> {
double
_noIntrinsicExtent
(
BoxConstraints
constraints
)
{
assert
(()
{
'MixedViewport does not support returning intrinsic dimensions. '
+
'Calculating the intrinsic dimensions would require walking the entire child list, '
+
'which defeats the entire point of having a lazily-built list of children.'
;
return
RenderObject
.
debugInDebugDoesMeetConstraints
;
if
(!
RenderObject
.
debugCheckingIntrinsics
)
{
throw
new
UnsupportedError
(
'MixedViewport does not support returning intrinsic dimensions.
\n
'
'Calculating the intrinsic dimensions would require walking the entire child list,
\n
'
'which defeats the entire point of having a lazily-built list of children.'
);
}
return
true
;
});
return
null
;
}
...
...
packages/flutter/lib/src/widgets/scrollable.dart
View file @
cb9152ca
...
...
@@ -442,13 +442,14 @@ class ScrollableViewportState extends ScrollableState<ScrollableViewport> {
class
Block
extends
StatelessComponent
{
Block
({
Key
key
,
this
.
children
,
this
.
children
:
const
<
Widget
>[]
,
this
.
padding
,
this
.
initialScrollOffset
,
this
.
scrollDirection
:
Axis
.
vertical
,
this
.
onScroll
,
this
.
scrollableKey
})
:
super
(
key:
key
)
{
assert
(
children
!=
null
);
assert
(!
children
.
any
((
Widget
child
)
=>
child
==
null
));
}
...
...
packages/flutter/test/widget/custom_multi_child_layout_test.dart
View file @
cb9152ca
...
...
@@ -11,7 +11,7 @@ class TestMultiChildLayoutDelegate extends MultiChildLayoutDelegate {
BoxConstraints
getSizeConstraints
;
Size
getSize
(
BoxConstraints
constraints
)
{
if
(!
RenderObject
.
debug
InDebugDoesMeetConstraint
s
)
if
(!
RenderObject
.
debug
CheckingIntrinsic
s
)
getSizeConstraints
=
constraints
;
return
new
Size
(
200.0
,
300.0
);
}
...
...
@@ -23,7 +23,7 @@ class TestMultiChildLayoutDelegate extends MultiChildLayoutDelegate {
bool
performLayoutIsChild
;
void
performLayout
(
Size
size
,
BoxConstraints
constraints
)
{
assert
(!
RenderObject
.
debug
InDebugDoesMeetConstraint
s
);
assert
(!
RenderObject
.
debug
CheckingIntrinsic
s
);
expect
(()
{
performLayoutSize
=
size
;
performLayoutConstraints
=
constraints
;
...
...
@@ -36,7 +36,7 @@ class TestMultiChildLayoutDelegate extends MultiChildLayoutDelegate {
bool
shouldRelayoutCalled
=
false
;
bool
shouldRelayoutValue
=
false
;
bool
shouldRelayout
(
_
)
{
assert
(!
RenderObject
.
debug
InDebugDoesMeetConstraint
s
);
assert
(!
RenderObject
.
debug
CheckingIntrinsic
s
);
shouldRelayoutCalled
=
true
;
return
shouldRelayoutValue
;
}
...
...
packages/flutter/test/widget/custom_one_child_layout_test.dart
View file @
cb9152ca
...
...
@@ -14,13 +14,13 @@ class TestOneChildLayoutDelegate extends OneChildLayoutDelegate {
Size
childSizeFromGetPositionForChild
;
Size
getSize
(
BoxConstraints
constraints
)
{
if
(!
RenderObject
.
debug
InDebugDoesMeetConstraint
s
)
if
(!
RenderObject
.
debug
CheckingIntrinsic
s
)
constraintsFromGetSize
=
constraints
;
return
new
Size
(
200.0
,
300.0
);
}
BoxConstraints
getConstraintsForChild
(
BoxConstraints
constraints
)
{
assert
(!
RenderObject
.
debug
InDebugDoesMeetConstraint
s
);
assert
(!
RenderObject
.
debug
CheckingIntrinsic
s
);
constraintsFromGetConstraintsForChild
=
constraints
;
return
new
BoxConstraints
(
minWidth:
100.0
,
...
...
@@ -31,7 +31,7 @@ class TestOneChildLayoutDelegate extends OneChildLayoutDelegate {
}
Offset
getPositionForChild
(
Size
size
,
Size
childSize
)
{
assert
(!
RenderObject
.
debug
InDebugDoesMeetConstraint
s
);
assert
(!
RenderObject
.
debug
CheckingIntrinsic
s
);
sizeFromGetPositionForChild
=
size
;
childSizeFromGetPositionForChild
=
childSize
;
return
Offset
.
zero
;
...
...
@@ -40,7 +40,7 @@ class TestOneChildLayoutDelegate extends OneChildLayoutDelegate {
bool
shouldRelayoutCalled
=
false
;
bool
shouldRelayoutValue
=
false
;
bool
shouldRelayout
(
_
)
{
assert
(!
RenderObject
.
debug
InDebugDoesMeetConstraint
s
);
assert
(!
RenderObject
.
debug
CheckingIntrinsic
s
);
shouldRelayoutCalled
=
true
;
return
shouldRelayoutValue
;
}
...
...
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