Skip to content

Commit

Permalink
Fix Ink decoration image does not render (#121521)
Browse files Browse the repository at this point in the history
  • Loading branch information
bleroux authored Feb 27, 2023
1 parent d193f05 commit a297cb3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/flutter/lib/src/material/ink_decoration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ class _InkState extends State<Ink> {
_ink!.decoration = widget.decoration;
_ink!.configuration = createLocalImageConfiguration(context);
}
return widget.child ?? const SizedBox();
return widget.child ?? ConstrainedBox(constraints: const BoxConstraints.expand());
}

@override
Expand Down
36 changes: 22 additions & 14 deletions packages/flutter/test/material/ink_paint_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,17 @@ import 'package:flutter_test/flutter_test.dart';
import '../rendering/mock_canvas.dart';

void main() {
testWidgets('The Ink widget renders a SizedBox by default', (WidgetTester tester) async {
testWidgets('The Ink widget expands when no dimensions are set', (WidgetTester tester) async {
await tester.pumpWidget(
Material(
child: Ink(),
),
);
Finder sizedBox = find.descendant(
of: find.byType(Ink),
matching: find.byType(SizedBox),
);
expect(sizedBox, findsOneWidget);
expect(tester.getSize(sizedBox).height, 600.0);
expect(tester.getSize(sizedBox).width, 800.0);
expect(find.byType(Ink), findsOneWidget);
expect(tester.getSize(find.byType(Ink)), const Size(800.0, 600.0));
});

testWidgets('The Ink widget fits the specified size', (WidgetTester tester) async {
const double height = 150.0;
const double width = 200.0;
await tester.pumpWidget(
Expand All @@ -36,13 +33,24 @@ void main() {
),
);
await tester.pumpAndSettle();
sizedBox = find.descendant(
of: find.byType(Ink),
matching: find.byType(SizedBox),
expect(find.byType(Ink), findsOneWidget);
expect(tester.getSize(find.byType(Ink)), const Size(width, height));
});

testWidgets('The Ink widget expands on a unspecified dimension', (WidgetTester tester) async {
const double height = 150.0;
await tester.pumpWidget(
Material(
child: Center( // used to constrain to child's size
child: Ink(
height: height,
),
),
),
);
expect(sizedBox, findsNWidgets(2));
expect(tester.getSize(sizedBox.at(0)).height, height);
expect(tester.getSize(sizedBox.at(0)).width, width);
await tester.pumpAndSettle();
expect(find.byType(Ink), findsOneWidget);
expect(tester.getSize(find.byType(Ink)), const Size(800, height));
});

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

0 comments on commit a297cb3

Please sign in to comment.