Skip to content

Commit a297cb3

Browse files
authored
Fix Ink decoration image does not render (#121521)
1 parent d193f05 commit a297cb3

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

packages/flutter/lib/src/material/ink_decoration.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ class _InkState extends State<Ink> {
288288
_ink!.decoration = widget.decoration;
289289
_ink!.configuration = createLocalImageConfiguration(context);
290290
}
291-
return widget.child ?? const SizedBox();
291+
return widget.child ?? ConstrainedBox(constraints: const BoxConstraints.expand());
292292
}
293293

294294
@override

packages/flutter/test/material/ink_paint_test.dart

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,17 @@ import 'package:flutter_test/flutter_test.dart';
99
import '../rendering/mock_canvas.dart';
1010

1111
void main() {
12-
testWidgets('The Ink widget renders a SizedBox by default', (WidgetTester tester) async {
12+
testWidgets('The Ink widget expands when no dimensions are set', (WidgetTester tester) async {
1313
await tester.pumpWidget(
1414
Material(
1515
child: Ink(),
1616
),
1717
);
18-
Finder sizedBox = find.descendant(
19-
of: find.byType(Ink),
20-
matching: find.byType(SizedBox),
21-
);
22-
expect(sizedBox, findsOneWidget);
23-
expect(tester.getSize(sizedBox).height, 600.0);
24-
expect(tester.getSize(sizedBox).width, 800.0);
18+
expect(find.byType(Ink), findsOneWidget);
19+
expect(tester.getSize(find.byType(Ink)), const Size(800.0, 600.0));
20+
});
2521

22+
testWidgets('The Ink widget fits the specified size', (WidgetTester tester) async {
2623
const double height = 150.0;
2724
const double width = 200.0;
2825
await tester.pumpWidget(
@@ -36,13 +33,24 @@ void main() {
3633
),
3734
);
3835
await tester.pumpAndSettle();
39-
sizedBox = find.descendant(
40-
of: find.byType(Ink),
41-
matching: find.byType(SizedBox),
36+
expect(find.byType(Ink), findsOneWidget);
37+
expect(tester.getSize(find.byType(Ink)), const Size(width, height));
38+
});
39+
40+
testWidgets('The Ink widget expands on a unspecified dimension', (WidgetTester tester) async {
41+
const double height = 150.0;
42+
await tester.pumpWidget(
43+
Material(
44+
child: Center( // used to constrain to child's size
45+
child: Ink(
46+
height: height,
47+
),
48+
),
49+
),
4250
);
43-
expect(sizedBox, findsNWidgets(2));
44-
expect(tester.getSize(sizedBox.at(0)).height, height);
45-
expect(tester.getSize(sizedBox.at(0)).width, width);
51+
await tester.pumpAndSettle();
52+
expect(find.byType(Ink), findsOneWidget);
53+
expect(tester.getSize(find.byType(Ink)), const Size(800, height));
4654
});
4755

4856
testWidgets('The InkWell widget renders an ink splash', (WidgetTester tester) async {

0 commit comments

Comments
 (0)