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
64a23504
Unverified
Commit
64a23504
authored
Sep 30, 2020
by
Anhad Singh
Committed by
GitHub
Sep 30, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added transformAlignment for container (#66201)
parent
becaf491
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
1 deletion
+58
-1
container.dart
packages/flutter/lib/src/widgets/container.dart
+11
-1
container_test.dart
packages/flutter/test/widgets/container_test.dart
+47
-0
No files found.
packages/flutter/lib/src/widgets/container.dart
View file @
64a23504
...
...
@@ -268,6 +268,7 @@ class Container extends StatelessWidget {
BoxConstraints
?
constraints
,
this
.
margin
,
this
.
transform
,
this
.
transformAlignment
,
this
.
child
,
this
.
clipBehavior
=
Clip
.
none
,
})
:
assert
(
margin
==
null
||
margin
.
isNonNegative
),
...
...
@@ -356,6 +357,15 @@ class Container extends StatelessWidget {
/// The transformation matrix to apply before painting the container.
final
Matrix4
?
transform
;
/// The alignment of the origin, relative to the size of the container, if [transform] is specified.
///
/// When [transform] is null, the value of this property is ignored.
///
/// See also:
///
/// * [Transform.alignment], which is set by this property.
final
Alignment
?
transformAlignment
;
/// The clip behavior when [Container.decoration] is not null.
///
/// Defaults to [Clip.none]. Must be [Clip.none] if [decoration] is null.
...
...
@@ -427,7 +437,7 @@ class Container extends StatelessWidget {
current
=
Padding
(
padding:
margin
!,
child:
current
);
if
(
transform
!=
null
)
current
=
Transform
(
transform:
transform
!,
child:
current
);
current
=
Transform
(
transform:
transform
!,
child:
current
,
alignment:
transformAlignment
);
return
current
!;
}
...
...
packages/flutter/test/widgets/container_test.dart
View file @
64a23504
...
...
@@ -470,6 +470,53 @@ void main() {
);
});
testWidgets
(
'Container transformAlignment'
,
(
WidgetTester
tester
)
async
{
final
Key
key
=
UniqueKey
();
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Stack
(
children:
<
Widget
>[
Positioned
(
top:
100.0
,
left:
100.0
,
child:
Container
(
width:
100.0
,
height:
100.0
,
color:
const
Color
(
0xFF0000FF
),
),
),
Positioned
(
top:
100.0
,
left:
100.0
,
child:
Container
(
width:
100.0
,
height:
100.0
,
key:
key
,
transform:
Matrix4
.
diagonal3Values
(
0.5
,
0.5
,
1.0
),
transformAlignment:
const
Alignment
(
1.0
,
0.0
),
child:
Container
(
color:
const
Color
(
0xFF00FFFF
),
),
),
),
],
),
),
);
final
Finder
finder
=
find
.
byKey
(
key
);
expect
(
tester
.
getSize
(
finder
),
equals
(
const
Size
(
100
,
100
)));
expect
(
tester
.
getTopLeft
(
finder
),
equals
(
const
Offset
(
100
,
100
)));
expect
(
tester
.
getTopRight
(
finder
),
equals
(
const
Offset
(
200
,
100
)));
expect
(
tester
.
getBottomLeft
(
finder
),
equals
(
const
Offset
(
100
,
200
)));
expect
(
tester
.
getBottomRight
(
finder
),
equals
(
const
Offset
(
200
,
200
)));
});
testWidgets
(
'giving clipBehaviour Clip.None, will not add a ClipPath to the tree'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
Container
(
clipBehavior:
Clip
.
none
,
...
...
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