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
6a323f6f
Commit
6a323f6f
authored
Sep 01, 2016
by
Ian Hickson
Committed by
GitHub
Sep 01, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Try to help people using intrinsic dimension methods more. (#5712)
parent
f27fa0ec
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
94 additions
and
0 deletions
+94
-0
box.dart
packages/flutter/lib/src/rendering/box.dart
+94
-0
No files found.
packages/flutter/lib/src/rendering/box.dart
View file @
6a323f6f
...
@@ -550,6 +550,25 @@ abstract class RenderBox extends RenderObject {
...
@@ -550,6 +550,25 @@ abstract class RenderBox extends RenderObject {
/// Do not override this method. Instead, implement [computeMinIntrinsicWidth].
/// Do not override this method. Instead, implement [computeMinIntrinsicWidth].
@mustCallSuper
@mustCallSuper
double
getMinIntrinsicWidth
(
double
height
)
{
double
getMinIntrinsicWidth
(
double
height
)
{
assert
(()
{
if
(
height
==
null
)
{
throw
new
FlutterError
(
'The height argument to getMinIntrinsicWidth was null.
\n
'
'The argument to getMinIntrinsicWidth must not be negative or null. '
'If you do not have a specific height in mind, then pass double.INFINITY instead.'
);
}
if
(
height
<
0.0
)
{
throw
new
FlutterError
(
'The height argument to getMinIntrinsicWidth was negative.
\n
'
'The argument to getMinIntrinsicWidth must not be negative or null. '
'If you perform computations on another height before passing it to '
'getMinIntrinsicWidth, consider using math.max() or double.clamp() '
'to force the value into the valid range.'
);
}
return
true
;
});
return
_computeIntrinsicDimension
(
_IntrinsicDimension
.
minWidth
,
height
,
computeMinIntrinsicWidth
);
return
_computeIntrinsicDimension
(
_IntrinsicDimension
.
minWidth
,
height
,
computeMinIntrinsicWidth
);
}
}
...
@@ -570,6 +589,8 @@ abstract class RenderBox extends RenderObject {
...
@@ -570,6 +589,8 @@ abstract class RenderBox extends RenderObject {
/// height-in-width-out when the width is unconstrained, then the height
/// height-in-width-out when the width is unconstrained, then the height
/// argument is the height to use.
/// argument is the height to use.
///
///
/// The `height` argument will never be negative or null. It may be infinite.
///
/// If this algorithm depends on the intrinsic dimensions of a child, the
/// If this algorithm depends on the intrinsic dimensions of a child, the
/// intrinsic dimensions of that child should be obtained using the functions
/// intrinsic dimensions of that child should be obtained using the functions
/// whose names start with `get`, not `compute`.
/// whose names start with `get`, not `compute`.
...
@@ -640,6 +661,11 @@ abstract class RenderBox extends RenderObject {
...
@@ -640,6 +661,11 @@ abstract class RenderBox extends RenderObject {
/// decreases the preferred height. The preferred height is the value that
/// decreases the preferred height. The preferred height is the value that
/// would be returned by [getMinIntrinsicHeight] for that width.
/// would be returned by [getMinIntrinsicHeight] for that width.
///
///
/// The height argument may give a specific height to assume. The given height
/// can be infinite, meaning that the intrinsic width in an unconstrained
/// environment is being requested. The given height should never be negative
/// or null.
///
/// This function should only be called on one's children. Calling this
/// This function should only be called on one's children. Calling this
/// function couples the child with the parent so that when the child's layout
/// function couples the child with the parent so that when the child's layout
/// changes, the parent is notified (via [markNeedsLayout]).
/// changes, the parent is notified (via [markNeedsLayout]).
...
@@ -651,6 +677,25 @@ abstract class RenderBox extends RenderObject {
...
@@ -651,6 +677,25 @@ abstract class RenderBox extends RenderObject {
/// [computeMaxIntrinsicWidth].
/// [computeMaxIntrinsicWidth].
@mustCallSuper
@mustCallSuper
double
getMaxIntrinsicWidth
(
double
height
)
{
double
getMaxIntrinsicWidth
(
double
height
)
{
assert
(()
{
if
(
height
==
null
)
{
throw
new
FlutterError
(
'The height argument to getMaxIntrinsicWidth was null.
\n
'
'The argument to getMaxIntrinsicWidth must not be negative or null. '
'If you do not have a specific height in mind, then pass double.INFINITY instead.'
);
}
if
(
height
<
0.0
)
{
throw
new
FlutterError
(
'The height argument to getMaxIntrinsicWidth was negative.
\n
'
'The argument to getMaxIntrinsicWidth must not be negative or null. '
'If you perform computations on another height before passing it to '
'getMaxIntrinsicWidth, consider using math.max() or double.clamp() '
'to force the value into the valid range.'
);
}
return
true
;
});
return
_computeIntrinsicDimension
(
_IntrinsicDimension
.
maxWidth
,
height
,
computeMaxIntrinsicWidth
);
return
_computeIntrinsicDimension
(
_IntrinsicDimension
.
maxWidth
,
height
,
computeMaxIntrinsicWidth
);
}
}
...
@@ -670,6 +715,8 @@ abstract class RenderBox extends RenderObject {
...
@@ -670,6 +715,8 @@ abstract class RenderBox extends RenderObject {
/// should be equal to or bigger than the value returned by
/// should be equal to or bigger than the value returned by
/// [computeMinIntrinsicWidth].
/// [computeMinIntrinsicWidth].
///
///
/// The `height` argument will never be negative or null. It may be infinite.
///
/// The value returned by this method might not match the size that the object
/// The value returned by this method might not match the size that the object
/// would actually take. For example, a [RenderBox] subclass that always
/// would actually take. For example, a [RenderBox] subclass that always
/// exactly sizes itself using [BoxConstraints.biggest] might well size itself
/// exactly sizes itself using [BoxConstraints.biggest] might well size itself
...
@@ -706,6 +753,25 @@ abstract class RenderBox extends RenderObject {
...
@@ -706,6 +753,25 @@ abstract class RenderBox extends RenderObject {
/// [computeMinIntrinsicHeight].
/// [computeMinIntrinsicHeight].
@mustCallSuper
@mustCallSuper
double
getMinIntrinsicHeight
(
double
width
)
{
double
getMinIntrinsicHeight
(
double
width
)
{
assert
(()
{
if
(
width
==
null
)
{
throw
new
FlutterError
(
'The width argument to getMinIntrinsicHeight was null.
\n
'
'The argument to getMinIntrinsicHeight must not be negative or null. '
'If you do not have a specific width in mind, then pass double.INFINITY instead.'
);
}
if
(
width
<
0.0
)
{
throw
new
FlutterError
(
'The width argument to getMinIntrinsicHeight was negative.
\n
'
'The argument to getMinIntrinsicHeight must not be negative or null. '
'If you perform computations on another width before passing it to '
'getMinIntrinsicHeight, consider using math.max() or double.clamp() '
'to force the value into the valid range.'
);
}
return
true
;
});
return
_computeIntrinsicDimension
(
_IntrinsicDimension
.
minHeight
,
width
,
computeMinIntrinsicHeight
);
return
_computeIntrinsicDimension
(
_IntrinsicDimension
.
minHeight
,
width
,
computeMinIntrinsicHeight
);
}
}
...
@@ -726,6 +792,8 @@ abstract class RenderBox extends RenderObject {
...
@@ -726,6 +792,8 @@ abstract class RenderBox extends RenderObject {
/// width-in-height-out when the height is unconstrained, then the width
/// width-in-height-out when the height is unconstrained, then the width
/// argument is the width to use.
/// argument is the width to use.
///
///
/// The `width` argument will never be negative or null. It may be infinite.
///
/// If this algorithm depends on the intrinsic dimensions of a child, the
/// If this algorithm depends on the intrinsic dimensions of a child, the
/// intrinsic dimensions of that child should be obtained using the functions
/// intrinsic dimensions of that child should be obtained using the functions
/// whose names start with `get`, not `compute`.
/// whose names start with `get`, not `compute`.
...
@@ -742,6 +810,11 @@ abstract class RenderBox extends RenderObject {
...
@@ -742,6 +810,11 @@ abstract class RenderBox extends RenderObject {
/// decreases the preferred width. The preferred width is the value that
/// decreases the preferred width. The preferred width is the value that
/// would be returned by [getMinIntrinsicWidth] for that height.
/// would be returned by [getMinIntrinsicWidth] for that height.
///
///
/// The width argument may give a specific width to assume. The given width
/// can be infinite, meaning that the intrinsic height in an unconstrained
/// environment is being requested. The given width should never be negative
/// or null.
///
/// This function should only be called on one's children. Calling this
/// This function should only be called on one's children. Calling this
/// function couples the child with the parent so that when the child's layout
/// function couples the child with the parent so that when the child's layout
/// changes, the parent is notified (via [markNeedsLayout]).
/// changes, the parent is notified (via [markNeedsLayout]).
...
@@ -753,6 +826,25 @@ abstract class RenderBox extends RenderObject {
...
@@ -753,6 +826,25 @@ abstract class RenderBox extends RenderObject {
/// [computeMaxIntrinsicHeight].
/// [computeMaxIntrinsicHeight].
@mustCallSuper
@mustCallSuper
double
getMaxIntrinsicHeight
(
double
width
)
{
double
getMaxIntrinsicHeight
(
double
width
)
{
assert
(()
{
if
(
width
==
null
)
{
throw
new
FlutterError
(
'The width argument to getMaxIntrinsicHeight was null.
\n
'
'The argument to getMaxIntrinsicHeight must not be negative or null. '
'If you do not have a specific width in mind, then pass double.INFINITY instead.'
);
}
if
(
width
<
0.0
)
{
throw
new
FlutterError
(
'The width argument to getMaxIntrinsicHeight was negative.
\n
'
'The argument to getMaxIntrinsicHeight must not be negative or null. '
'If you perform computations on another width before passing it to '
'getMaxIntrinsicHeight, consider using math.max() or double.clamp() '
'to force the value into the valid range.'
);
}
return
true
;
});
return
_computeIntrinsicDimension
(
_IntrinsicDimension
.
maxHeight
,
width
,
computeMaxIntrinsicHeight
);
return
_computeIntrinsicDimension
(
_IntrinsicDimension
.
maxHeight
,
width
,
computeMaxIntrinsicHeight
);
}
}
...
@@ -772,6 +864,8 @@ abstract class RenderBox extends RenderObject {
...
@@ -772,6 +864,8 @@ abstract class RenderBox extends RenderObject {
/// should be equal to or bigger than the value returned by
/// should be equal to or bigger than the value returned by
/// [computeMinIntrinsicHeight].
/// [computeMinIntrinsicHeight].
///
///
/// The `width` argument will never be negative or null. It may be infinite.
///
/// The value returned by this method might not match the size that the object
/// The value returned by this method might not match the size that the object
/// would actually take. For example, a [RenderBox] subclass that always
/// would actually take. For example, a [RenderBox] subclass that always
/// exactly sizes itself using [BoxConstraints.biggest] might well size itself
/// exactly sizes itself using [BoxConstraints.biggest] might well size itself
...
...
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