Unverified Commit ddd5ccd0 authored by Shi-Hao Hong's avatar Shi-Hao Hong Committed by GitHub

Add Container fallback to Ink build method (#35282)

* Add Container fallback to Ink build method

* Add tests for Ink container fallback
parent 9e1b4b22
...@@ -263,7 +263,7 @@ class _InkState extends State<Ink> { ...@@ -263,7 +263,7 @@ class _InkState extends State<Ink> {
final EdgeInsetsGeometry effectivePadding = widget._paddingIncludingDecoration; final EdgeInsetsGeometry effectivePadding = widget._paddingIncludingDecoration;
if (effectivePadding != null) if (effectivePadding != null)
current = Padding(padding: effectivePadding, child: current); current = Padding(padding: effectivePadding, child: current);
return current; return current ?? Container();
} }
@override @override
......
...@@ -9,6 +9,32 @@ import 'package:flutter_test/flutter_test.dart'; ...@@ -9,6 +9,32 @@ 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 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 { testWidgets('The InkWell widget renders an ink splash', (WidgetTester tester) async {
const Color highlightColor = Color(0xAAFF0000); const Color highlightColor = Color(0xAAFF0000);
const Color splashColor = Color(0xAA0000FF); const Color splashColor = Color(0xAA0000FF);
......
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