Unverified Commit 64a23504 authored by Anhad Singh's avatar Anhad Singh Committed by GitHub

Added transformAlignment for container (#66201)

parent becaf491
......@@ -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!;
}
......
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment