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:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user