Unverified Commit f9331e2c authored by Mahesh Jamdade's avatar Mahesh Jamdade Committed by GitHub

Pass fit property to RenderIndexedStack (#109295)

parent f4a64ef0
......@@ -714,6 +714,8 @@ class RenderIndexedStack extends RenderStack {
super.children,
super.alignment,
super.textDirection,
super.fit,
super.clipBehavior,
int? index = 0,
}) : _index = index;
......
......@@ -3943,6 +3943,7 @@ class IndexedStack extends Stack {
super.key,
super.alignment,
super.textDirection,
super.clipBehavior,
StackFit sizing = StackFit.loose,
this.index = 0,
super.children,
......@@ -3956,6 +3957,8 @@ class IndexedStack extends Stack {
assert(_debugCheckHasDirectionality(context));
return RenderIndexedStack(
index: index,
fit:fit,
clipBehavior: clipBehavior,
alignment: alignment,
textDirection: textDirection ?? Directionality.maybeOf(context),
);
......@@ -3966,6 +3969,8 @@ class IndexedStack extends Stack {
assert(_debugCheckHasDirectionality(context));
renderObject
..index = index
..fit = fit
..clipBehavior = clipBehavior
..alignment = alignment
..textDirection = textDirection ?? Directionality.maybeOf(context);
}
......
......@@ -799,4 +799,64 @@ void main() {
"'alignment', or an explicit 'textDirection', to the Stack.",
);
});
testWidgets('Can update clipBehavior of IndexedStack',
(WidgetTester tester) async {
await tester.pumpWidget(IndexedStack(textDirection: TextDirection.ltr));
final RenderIndexedStack renderObject =
tester.renderObject<RenderIndexedStack>(find.byType(IndexedStack));
expect(renderObject.clipBehavior, equals(Clip.hardEdge));
// Update clipBehavior to Clip.antiAlias
await tester.pumpWidget(IndexedStack(
textDirection: TextDirection.ltr,
clipBehavior: Clip.antiAlias,
));
final RenderIndexedStack renderIndexedObject =
tester.renderObject<RenderIndexedStack>(find.byType(IndexedStack));
expect(renderIndexedObject.clipBehavior, equals(Clip.antiAlias));
});
testWidgets('IndexedStack sizing: explicit', (WidgetTester tester) async {
final List<String> logs = <String>[];
Widget buildIndexedStack(StackFit sizing) {
return Directionality(
textDirection: TextDirection.ltr,
child: Center(
child: ConstrainedBox(
constraints: const BoxConstraints(
minWidth: 2.0,
maxWidth: 3.0,
minHeight: 5.0,
maxHeight: 7.0,
),
child: IndexedStack(
sizing: sizing,
children: <Widget>[
LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
logs.add(constraints.toString());
return const Placeholder();
},
),
],
),
),
),
);
}
await tester.pumpWidget(buildIndexedStack(StackFit.loose));
logs.add('=1=');
await tester.pumpWidget(buildIndexedStack(StackFit.expand));
logs.add('=2=');
await tester.pumpWidget(buildIndexedStack(StackFit.passthrough));
expect(logs, <String>[
'BoxConstraints(0.0<=w<=3.0, 0.0<=h<=7.0)',
'=1=',
'BoxConstraints(w=3.0, h=7.0)',
'=2=',
'BoxConstraints(2.0<=w<=3.0, 5.0<=h<=7.0)',
]);
});
}
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