Unverified Commit a297cb36 authored by Bruno Leroux's avatar Bruno Leroux Committed by GitHub

Fix Ink decoration image does not render (#121521)

parent d193f050
...@@ -288,7 +288,7 @@ class _InkState extends State<Ink> { ...@@ -288,7 +288,7 @@ class _InkState extends State<Ink> {
_ink!.decoration = widget.decoration; _ink!.decoration = widget.decoration;
_ink!.configuration = createLocalImageConfiguration(context); _ink!.configuration = createLocalImageConfiguration(context);
} }
return widget.child ?? const SizedBox(); return widget.child ?? ConstrainedBox(constraints: const BoxConstraints.expand());
} }
@override @override
......
...@@ -9,20 +9,17 @@ import 'package:flutter_test/flutter_test.dart'; ...@@ -9,20 +9,17 @@ import 'package:flutter_test/flutter_test.dart';
import '../rendering/mock_canvas.dart'; import '../rendering/mock_canvas.dart';
void main() { 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( await tester.pumpWidget(
Material( Material(
child: Ink(), child: Ink(),
), ),
); );
Finder sizedBox = find.descendant( expect(find.byType(Ink), findsOneWidget);
of: find.byType(Ink), expect(tester.getSize(find.byType(Ink)), const Size(800.0, 600.0));
matching: find.byType(SizedBox), });
);
expect(sizedBox, findsOneWidget);
expect(tester.getSize(sizedBox).height, 600.0);
expect(tester.getSize(sizedBox).width, 800.0);
testWidgets('The Ink widget fits the specified size', (WidgetTester tester) async {
const double height = 150.0; const double height = 150.0;
const double width = 200.0; const double width = 200.0;
await tester.pumpWidget( await tester.pumpWidget(
...@@ -36,13 +33,24 @@ void main() { ...@@ -36,13 +33,24 @@ void main() {
), ),
); );
await tester.pumpAndSettle(); await tester.pumpAndSettle();
sizedBox = find.descendant( expect(find.byType(Ink), findsOneWidget);
of: find.byType(Ink), expect(tester.getSize(find.byType(Ink)), const Size(width, height));
matching: find.byType(SizedBox), });
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)); await tester.pumpAndSettle();
expect(tester.getSize(sizedBox.at(0)).height, height); expect(find.byType(Ink), findsOneWidget);
expect(tester.getSize(sizedBox.at(0)).width, width); expect(tester.getSize(find.byType(Ink)), const Size(800, height));
}); });
testWidgets('The InkWell widget renders an ink splash', (WidgetTester tester) async { testWidgets('The InkWell widget renders an ink splash', (WidgetTester tester) async {
......
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