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
8c44abc0
Unverified
Commit
8c44abc0
authored
Mar 19, 2021
by
LongCatIsLooong
Committed by
GitHub
Mar 19, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ConstraintsTransformBox (#77994)
parent
74a795d1
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
473 additions
and
88 deletions
+473
-88
debug_overflow_indicator.dart
...s/flutter/lib/src/rendering/debug_overflow_indicator.dart
+2
-1
shifted_box.dart
packages/flutter/lib/src/rendering/shifted_box.dart
+160
-69
basic.dart
packages/flutter/lib/src/widgets/basic.dart
+247
-16
box_test.dart
packages/flutter/test/rendering/box_test.dart
+42
-0
debug_overflow_indicator_test.dart
...flutter/test/rendering/debug_overflow_indicator_test.dart
+1
-1
basic_test.dart
packages/flutter/test/widgets/basic_test.dart
+21
-1
No files found.
packages/flutter/lib/src/rendering/debug_overflow_indicator.dart
View file @
8c44abc0
...
...
@@ -85,7 +85,8 @@ class _OverflowRegionData {
///
/// See also:
///
/// * [RenderUnconstrainedBox] and [RenderFlex] for examples of classes that use this indicator mixin.
/// * [RenderConstraintsTransformBox], [RenderUnconstrainedBox] and
/// [RenderFlex], for examples of classes that use this indicator mixin.
mixin
DebugOverflowIndicatorMixin
on
RenderObject
{
static
const
Color
_black
=
Color
(
0xBF000000
);
static
const
Color
_yellow
=
Color
(
0xBFFFFF00
);
...
...
packages/flutter/lib/src/rendering/shifted_box.dart
View file @
8c44abc0
This diff is collapsed.
Click to expand it.
packages/flutter/lib/src/widgets/basic.dart
View file @
8c44abc0
This diff is collapsed.
Click to expand it.
packages/flutter/test/rendering/box_test.dart
View file @
8c44abc0
...
...
@@ -378,6 +378,48 @@ void main() {
expect
(
unconstrained
.
getMaxIntrinsicWidth
(
100.0
),
equals
(
200.0
));
});
group
(
'ConstraintsTransfromBox'
,
()
{
FlutterErrorDetails
?
firstErrorDetails
;
void
exhaustErrors
()
{
FlutterErrorDetails
?
next
;
do
{
next
=
renderer
.
takeFlutterErrorDetails
();
firstErrorDetails
??=
next
;
}
while
(
next
!=
null
);
}
tearDown
(()
{
firstErrorDetails
=
null
;
});
test
(
'throws if the resulting constraints are not normalized'
,
()
{
final
RenderConstrainedBox
child
=
RenderConstrainedBox
(
additionalConstraints:
const
BoxConstraints
.
tightFor
(
height:
0
));
final
RenderConstraintsTransformBox
box
=
RenderConstraintsTransformBox
(
alignment:
Alignment
.
center
,
textDirection:
TextDirection
.
ltr
,
constraintsTransform:
(
BoxConstraints
constraints
)
=>
const
BoxConstraints
(
maxHeight:
-
1
,
minHeight:
200
),
child:
child
,
);
layout
(
box
,
constraints:
const
BoxConstraints
(),
onErrors:
exhaustErrors
);
expect
(
firstErrorDetails
?.
toString
(),
contains
(
'is not normalized'
));
});
test
(
'overflow is reported when insufficient size is given'
,
()
{
final
RenderConstrainedBox
child
=
RenderConstrainedBox
(
additionalConstraints:
const
BoxConstraints
.
tightFor
(
width:
double
.
maxFinite
));
final
RenderConstraintsTransformBox
box
=
RenderConstraintsTransformBox
(
alignment:
Alignment
.
center
,
textDirection:
TextDirection
.
ltr
,
constraintsTransform:
(
BoxConstraints
constraints
)
=>
constraints
.
copyWith
(
maxWidth:
double
.
infinity
),
child:
child
,
);
// No error reported.
layout
(
box
,
constraints:
const
BoxConstraints
(),
phase:
EnginePhase
.
composite
,
onErrors:
expectOverflowedErrors
);
});
});
test
(
'getMinIntrinsicWidth error handling'
,
()
{
final
RenderUnconstrainedBox
unconstrained
=
RenderUnconstrainedBox
(
textDirection:
TextDirection
.
ltr
,
...
...
packages/flutter/test/rendering/debug_overflow_indicator_test.dart
View file @
8c44abc0
...
...
@@ -36,7 +36,7 @@ void main() {
final
dynamic
exception
=
tester
.
takeException
();
expect
(
exception
,
isFlutterError
);
expect
(
exception
.
diagnostics
.
first
.
level
,
DiagnosticLevel
.
summary
);
expect
(
exception
.
diagnostics
.
first
.
toString
(),
startsWith
(
'A Render
Unconstrained
Box overflowed by '
));
expect
(
exception
.
diagnostics
.
first
.
toString
(),
startsWith
(
'A Render
ConstraintsTransform
Box overflowed by '
));
expect
(
find
.
byType
(
UnconstrainedBox
),
paints
..
rect
());
await
tester
.
pumpWidget
(
...
...
packages/flutter/test/widgets/basic_test.dart
View file @
8c44abc0
...
...
@@ -323,6 +323,7 @@ void main() {
const
UnconstrainedBox
(
constrainedAxis:
Axis
.
vertical
,).
toString
(),
equals
(
'UnconstrainedBox(alignment: Alignment.center, constrainedAxis: vertical)'
),
);
expect
(
const
UnconstrainedBox
(
constrainedAxis:
Axis
.
horizontal
,
textDirection:
TextDirection
.
rtl
,
alignment:
Alignment
.
topRight
).
toString
(),
equals
(
'UnconstrainedBox(alignment: Alignment.topRight, constrainedAxis: horizontal, textDirection: rtl)'
),
...
...
@@ -331,13 +332,32 @@ void main() {
testWidgets
(
'UnconstrainedBox can set and update clipBehavior'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
UnconstrainedBox
());
final
Render
UnconstrainedBox
renderObject
=
tester
.
allRenderObjects
.
whereType
<
RenderUnconstrained
Box
>().
first
;
final
Render
ConstraintsTransformBox
renderObject
=
tester
.
allRenderObjects
.
whereType
<
RenderConstraintsTransform
Box
>().
first
;
expect
(
renderObject
.
clipBehavior
,
equals
(
Clip
.
none
));
await
tester
.
pumpWidget
(
const
UnconstrainedBox
(
clipBehavior:
Clip
.
antiAlias
));
expect
(
renderObject
.
clipBehavior
,
equals
(
Clip
.
antiAlias
));
});
group
(
'ConstraintsTransformBox'
,
()
{
test
(
'toString'
,
()
{
expect
(
const
ConstraintsTransformBox
(
constraintsTransform:
ConstraintsTransformBox
.
unconstrained
,
).
toString
(),
equals
(
'ConstraintsTransformBox(alignment: Alignment.center, constraints transform: unconstrained)'
),
);
expect
(
const
ConstraintsTransformBox
(
textDirection:
TextDirection
.
rtl
,
alignment:
Alignment
.
topRight
,
constraintsTransform:
ConstraintsTransformBox
.
widthUnconstrained
,
).
toString
(),
equals
(
'ConstraintsTransformBox(alignment: Alignment.topRight, textDirection: rtl, constraints transform: width constraints removed)'
),
);
});
});
group
(
'ColoredBox'
,
()
{
late
_MockCanvas
mockCanvas
;
late
_MockPaintingContext
mockContext
;
...
...
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