Improve container widget (#98389)

This commit is contained in:
Reza Mirzaee 2022-03-05 02:41:19 +03:30 committed by GitHub
parent 513df67edb
commit d61caaad26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 3 deletions

View File

@ -389,10 +389,9 @@ class Container extends StatelessWidget {
maxHeight: 0.0,
child: ConstrainedBox(constraints: const BoxConstraints.expand()),
);
}
if (alignment != null)
} else if (alignment != null) {
current = Align(alignment: alignment!, child: current);
}
final EdgeInsetsGeometry? effectivePadding = _paddingIncludingDecoration;
if (effectivePadding != null)

View File

@ -633,6 +633,21 @@ void main() {
expect(tapped, false);
});
testWidgets('Container discards alignment when the child parameter is null and constraints is not Tight', (WidgetTester tester) async {
await tester.pumpWidget(
Container(
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(1)),
),
alignment: Alignment.centerLeft
));
expect(
find.byType(Align),
findsNothing,
);
});
testWidgets('using clipBehaviour and shadow, should not clip the shadow', (WidgetTester tester) async {
final Container container = Container(
clipBehavior: Clip.hardEdge,