Add Container fallback to Ink build method (#35282)

* Add Container fallback to Ink build method

* Add tests for Ink container fallback
This commit is contained in:
Shi-Hao Hong
2019-07-01 08:28:34 -07:00
committed by GitHub
parent 9e1b4b22c2
commit ddd5ccd011
2 changed files with 27 additions and 1 deletions

View File

@@ -263,7 +263,7 @@ class _InkState extends State<Ink> {
final EdgeInsetsGeometry effectivePadding = widget._paddingIncludingDecoration;
if (effectivePadding != null)
current = Padding(padding: effectivePadding, child: current);
return current;
return current ?? Container();
}
@override

View File

@@ -9,6 +9,32 @@ import 'package:flutter_test/flutter_test.dart';
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);