Add Container fallback to Ink build method (#35282)
* Add Container fallback to Ink build method
* Add tests for Ink container fallback
diff --git a/packages/flutter/lib/src/material/ink_decoration.dart b/packages/flutter/lib/src/material/ink_decoration.dart
index 3f191c8..447cc3e 100644
--- a/packages/flutter/lib/src/material/ink_decoration.dart
+++ b/packages/flutter/lib/src/material/ink_decoration.dart
@@ -263,7 +263,7 @@
final EdgeInsetsGeometry effectivePadding = widget._paddingIncludingDecoration;
if (effectivePadding != null)
current = Padding(padding: effectivePadding, child: current);
- return current;
+ return current ?? Container();
}
@override
diff --git a/packages/flutter/test/material/ink_paint_test.dart b/packages/flutter/test/material/ink_paint_test.dart
index aa267dc..03cd7c1 100644
--- a/packages/flutter/test/material/ink_paint_test.dart
+++ b/packages/flutter/test/material/ink_paint_test.dart
@@ -9,6 +9,32 @@
import '../rendering/mock_canvas.dart';
void main() {
+ testWidgets('The Ink widget renders a Container by default', (WidgetTester tester) async {
+ await tester.pumpWidget(
+ Material(
+ child: Ink(),
+ ),
+ );
+ expect(tester.getSize(find.byType(Container)).height, 600.0);
+ expect(tester.getSize(find.byType(Container)).width, 800.0);
+
+ const double height = 150.0;
+ const double width = 200.0;
+ await tester.pumpWidget(
+ Material(
+ child: Center( // used to constrain to child's size
+ child: Ink(
+ height: height,
+ width: width,
+ ),
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+ expect(tester.getSize(find.byType(Container)).height, height);
+ expect(tester.getSize(find.byType(Container)).width, width);
+ });
+
testWidgets('The InkWell widget renders an ink splash', (WidgetTester tester) async {
const Color highlightColor = Color(0xAAFF0000);
const Color splashColor = Color(0xAA0000FF);